Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
  2. Active: active (running) since Tue 2017-03-21 11:50:56 EET; 1 weeks 1 days ago
  3. Main PID: 1209 (mysqld)
  4.  
  5. tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
  6.  
  7. Status: inactive
  8.  
  9. Not shown: 993 closed ports
  10. PORT STATE SERVICE
  11. 21/tcp open ftp
  12. 22/tcp open ssh
  13. 25/tcp open smtp
  14. 80/tcp open http
  15. 110/tcp open pop3
  16. 143/tcp open imap
  17. 3306/tcp open mysql
  18.  
  19. private final String WEBAPP_DB = "jdbc:mysql://192.168.0.4:3306/myDataBase";
  20. private final String JDBC_DRIVER="com.mysql.jdbc.Driver";
  21. private final String USERNAME = "myUserName";
  22. private final String PASSWORD = "myPassWord";
  23.  
  24. Connection c = null;
  25. PreparedStatement stm = null;
  26.  
  27. sq = "SELECT * FROM Machines";
  28. try {
  29. Class.forName(JDBC_DRIVER);
  30. c = DriverManager.getConnection(WEBAPP_DB, USERNAME, PASSWORD);
  31. stm = c.prepareStatement(sq);
  32. ResultSet rs = stm.executeQuery();
  33.  
  34. while(rs.next()){
  35. System.out.println("Machine = " + rs.getInt("id"));
  36. }
  37.  
  38. } catch (SQLException e) {
  39. e.printStackTrace();
  40. } finally {
  41. if (stm != null) {
  42. stm.close();
  43. }
  44. if (c != null) {
  45. c.close();
  46. }
  47. }
  48.  
  49. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
  50. ...
  51. The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
  52. ...
  53. Caused by: java.net.ConnectException: Connection refused: connect
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement