• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connection problem

 
amitpith chand
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here's my code
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;

public class Testdb {

public static void main(String[] argv) throws ClassNotFoundException, SQLException {

System.out.println("-------- MySQL JDBC Connection Testing ------------");


Class.forName("com.mysql.jdbc.Driver");

System.out.println("MySQL JDBC Driver Registered!");
Connection connection = null;


connection = DriverManager
.getConnection("jdbc:mysql:\\localhost:3306/local MYSQL55","root", "root");



if (connection != null) {
System.out.println("You made it, take control your database now!");
} else {
System.out.println("Failed to make connection!");
}
}
}
output:
-------- MySQL JDBC Connection Testing ------------
MySQL JDBC Driver Registered!
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:mysql:\localhost:3306/hello
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Testdb.main(Testdb.java:19)
i have added mysql-connector-java-5.1.22-bin.jar .
but still it is giving me error
 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Replace the \\ with //.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic