Guest User

Untitled

a guest
Aug 23rd, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. Java MySQL - Named Pipe connection throws warning on close
  2. public static List<List> QueryDB(int RowValue) {
  3. List<Long> ValueList = new ArrayList();
  4.  
  5. try {
  6. try (Connection Connection_T = MySQLConnectionResources.createConnection()) {
  7. try (Statement Statement_T = Connection_T.createStatement()) {
  8. String String_T = "SELECT AColumn FROM ATable WHERE BColumn = " + RowValue + ";";
  9. try (ResultSet ResultSet_T = Statement_T.executeQuery(String_T)) {
  10. while (ResultSet_T.next()) {
  11. ValueList.add(ResultSet_T.getLong("AColumn"));
  12. }
  13. }
  14. }
  15. }
  16. } catch(SQLException SQLException_P) {
  17. System.err.println("ERROR: Failed to query the database.");
  18. ValueList.clear();
  19. }
  20.  
  21. List<List> Result_M = new ArrayList();
  22. Result_M.add(ValueList);
  23. return Result_M;
  24. }
  25.  
  26. Thu Sep 22 00:31:54 EDT 2011 WARN: Caught while disconnecting...
  27.  
  28. EXCEPTION STACK TRACE:
  29.  
  30.  
  31.  
  32. ** BEGIN NESTED EXCEPTION **
  33.  
  34. java.net.SocketException
  35. MESSAGE: Socket is not connected
  36.  
  37. STACKTRACE:
  38.  
  39. java.net.SocketException: Socket is not connected
  40. at java.net.Socket.shutdownInput(Socket.java:1456)
  41. at com.mysql.jdbc.MysqlIO.quit(MysqlIO.java:1687)
  42. at com.mysql.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:4368)
  43. at com.mysql.jdbc.ConnectionImpl.close(ConnectionImpl.java:1557)
  44. at ... my class/method here (my class.java:#)
  45.  
  46.  
  47. ** END NESTED EXCEPTION **
  48.  
  49. import java.sql.Connection;
  50. import java.sql.DriverManager;
  51. import java.sql.SQLException;
  52.  
  53. public final class main {
  54. public static void main(String[] args) {
  55. Connection conn = null;
  56. try {
  57. conn =
  58.  
  59. DriverManager.getConnection("jdbc:mysql:///database?socketFactory=com.mysql.jdbc.NamedPipeSocketFactory&namedPipePath=\\.\Pipe\mysql.sock",
  60. "root", "password");
  61.  
  62. conn.close();
  63.  
  64.  
  65. } catch (SQLException ex) {
  66. // handle any errors
  67. }
  68. }
  69. }
Add Comment
Please, Sign In to add comment