wood burning stoves 2.0*
The moose likes JDBC and the fly likes connection problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "connection problem " Watch "connection problem " New topic
Author

connection problem

amitpith chand
Greenhorn

Joined: Dec 29, 2012
Posts: 4
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

Joined: Oct 27, 2005
Posts: 19556
    
  16

Replace the \\ with //.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: connection problem
 
Similar Threads
Is there a MySQL server running on the machine/port you are trying to connect to?
Mysql+Applet Connection Problem, attention pls.
connecting to sql file
JDBC- mysql Connectivity Problem
JDBC + Localhost