Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
- Active: active (running) since Tue 2017-03-21 11:50:56 EET; 1 weeks 1 days ago
- Main PID: 1209 (mysqld)
- tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
- Status: inactive
- Not shown: 993 closed ports
- PORT STATE SERVICE
- 21/tcp open ftp
- 22/tcp open ssh
- 25/tcp open smtp
- 80/tcp open http
- 110/tcp open pop3
- 143/tcp open imap
- 3306/tcp open mysql
- private final String WEBAPP_DB = "jdbc:mysql://192.168.0.4:3306/myDataBase";
- private final String JDBC_DRIVER="com.mysql.jdbc.Driver";
- private final String USERNAME = "myUserName";
- private final String PASSWORD = "myPassWord";
- Connection c = null;
- PreparedStatement stm = null;
- sq = "SELECT * FROM Machines";
- try {
- Class.forName(JDBC_DRIVER);
- c = DriverManager.getConnection(WEBAPP_DB, USERNAME, PASSWORD);
- stm = c.prepareStatement(sq);
- ResultSet rs = stm.executeQuery();
- while(rs.next()){
- System.out.println("Machine = " + rs.getInt("id"));
- }
- } catch (SQLException e) {
- e.printStackTrace();
- } finally {
- if (stm != null) {
- stm.close();
- }
- if (c != null) {
- c.close();
- }
- }
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- ...
- The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
- ...
- Caused by: java.net.ConnectException: Connection refused: connect
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement