• Register
0 votes

Problem :

Facing following jdbc issue 

caused by: com.mysql.jdbc.exceptions.jdbc4.communicationsexception: communications link failure

6.9k points
edited by

1 Answer

0 votes

Solution :

Please find below best solution for your problem,

 Connection con = DriverManager.getConnection(
 "jdbc:mysql://localhost:3306/DBname", "root", "root");

Now replace the Localhost with your IP address
 Connection con = DriverManager.getConnection(
 "jdbc:mysql://", "root", "root");

36.1k points

Related questions

0 votes
2 answers 151 views
Problem : I want my database to talk to my Java programs. I am getting following error message. Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The ... (); // ResultSet result = stat.executeQuery( "select * from table" ); System.out.println("Connected?"); } }
asked Dec 10, 2019 alecxe 7.5k points
0 votes
1 answer 5 views
Problem: I want to check if the very specific value already exists in the database. I am currently accessing database from the java standalone app using the JDBC my queries for inserting records into the db are working so my setup and the connection are perfectly fine. ... near 'd-f05708071f8f' at line 1 But if I attempt to execute above command in the MySQL command line then it works properly.
asked 4 days ago Raphael Pacheco 2.6k points
0 votes
1 answer 10 views
Problem: I have only a little knowledge in MySQL. In MySQL currently I have two tables they are tableA and tableB. I am trying to execute below two queries on the tables: executeQuery(query1)  executeQuery(query2) But I am facing the following unexpected error: “Can not issue data manipulation statements with executeQuery().” I need support from the MySQL expert to fix my above error.
asked Jul 23 Raphael Pacheco 2.6k points
2 votes
1 answer 13 views
Problem: I am beginner to jTable. I have already attached the jTable to JDBC database. But I don’t know how to retrieve them. My requirement is the saved data must be shown if I restart my program but currently it is not working for me. I have ... studentName"); String myshool = myrs.getString("schoolName"); String myjoining = myrs.getString("joiningDate"); } Can somebody solve my problem ?
asked Mar 24 morrisBson 3.2k points
0 votes
2 answers 57 views
Problem : I am getting bellow error while trying to execute JDBC code java.sql.sqlexception: operation not allowed after resultset closed
asked Nov 1, 2019 peterlaw 6.9k points