No suitable driver found for...

When I try to cennect to a mysql database I get this error:

No suitable driver found for jdbc:mysql:127.0.0.1:3306/rehber/rehber

The Code is here:

CN = DriverManager.getConnection("jdbc:mysql:" + Adresse +"/" + DataBase +"/rehber", UserName, Password);

Error comes as exception:

int a;

try{

CN = DriverManager.getConnection("jdbc:mysql:" + Adresse +"/" + DataBase +"/rehber", UserName, Password);

a = 1;

}catch(Exception e){

System.err.println(e.getMessage());

a = 0;

}finally{

try{

if(CN !=null)

CN.close();

}catch(SQLException e){

System.err.println("SQL: " + e.getMessage());

a = 0;

}

}

return a;

Message was edited by:

Genomsaren

[1524 byte] By [Genomsarena] at [2007-11-27 6:57:46]
# 1
Re-read the MySQL Connector/J documentation how to build the URL the right way. http://dev.mysql.com/doc/refman/5.0/en/connector-j-usagenotes-basic.html
BalusCa at 2007-7-12 18:35:09 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
No suitable driver found for jdbc:mysql:127.0.0.1:3306/rehber/rehber indicates either the connection url is incorrect or the driver jar is not in the classpath. Use url:jdbc:mysql://localhost:3306/rehber
dvohra09a at 2007-7-12 18:35:09 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
> or the driver jar is not in the classpath.This should likely throw a completely different exception?
BalusCa at 2007-7-12 18:35:09 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
how can I understand that the driver is installed or not?I have installed a driver from MySQL's website. There is a file called mysql-connector-java-5.0.6-bin.jar in it. And I dont know how to install it?
Genomsarena at 2007-7-12 18:35:09 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
Did you use Class.forName(driverName) ? Probably the driver isn't registered with the driver manager (see the documentation for the driver).Aside from that it just has to be put on the classpath for your application - how you do that will depend upon how your application is
dcmintera at 2007-7-12 18:35:09 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6

> how can I understand that the driver is installed or

> not?

> I have installed a driver from MySQL's website. There

> is a file called mysql-connector-java-5.0.6-bin.jar

> in it. And I dont know how to install it?

So, you haven't clicked nor read the link I gave first?

BalusCa at 2007-7-12 18:35:09 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7
I have clicked but I understand now. Im new to java and classpath is new for me. Im working on that right now.
Genomsarena at 2007-7-12 18:35:10 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 8
Or the driver jar is not getting loaded.
dvohra09a at 2007-7-12 18:35:10 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 9
My conneciton string was incorrect I changed it now it is giving the same error again. I tried to add the driver to libraries. But I get the same error again. :S
Genomsarena at 2007-7-12 18:35:10 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 10

Here is the downlaod link:

http://rapidshare.com/files/36744482/Java_Deneme.rar.html

You can look the code if you want. It is my first "software" in java so you can find very amateur things in it. If you want to test the software you will need mysql server and a database called "rehber". Everything is turkish. If you want I can translate it until thursday. (Im busy today).

Baglan=Connect

Rehber=Where you save telephone numbers

Giris=Login

Veri Tabani=Database

Kullanıcı Adı=Username

Sifre=Password

Genomsarena at 2007-7-12 18:35:10 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...