Database Connection from Java
Java
2
Posts
2
Posters
0
Views
1
Watching
-
Hello, I am trying to connect to mysql from Java with the following but getting this error Exception in thread "main" Communications link failure
package testPackage;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;public class Main {
public static void main(String\[\] args) throws Exception { // TODO Auto-generated method stub try { Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/student?useSSL=true","root","success"); System.out.print("Database is connected !"); con.close(); } catch(Exception e) { System.out.println(e.getMessage()); throw e; } }
}
-
Hello, I am trying to connect to mysql from Java with the following but getting this error Exception in thread "main" Communications link failure
package testPackage;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;public class Main {
public static void main(String\[\] args) throws Exception { // TODO Auto-generated method stub try { Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/student?useSSL=true","root","success"); System.out.print("Database is connected !"); con.close(); } catch(Exception e) { System.out.println(e.getMessage()); throw e; } }
}