This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes No suitable driver found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "No suitable driver found" Watch "No suitable driver found" New topic
Author

No suitable driver found

chetan dhumane
Ranch Hand

Joined: Jan 07, 2009
Posts: 629

I am getting this exception

No suitable driver found for jdbc:mysql://localhost:3306/test?user=root;password=1234


I have also included MySQL Connector 5.1.7 driver And I am using JSP to get connection(from eclipse)

Thanks in advance


http://www.androcid.com/
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

chetan dhumane wrote:
No suitable driver found for jdbc:mysql://localhost:3306/test?user=root;password=1234


I have also included MySQL Connector 5.1.7 driver

Put those driver jar file on classpath.
chetan dhumane wrote:
And I am using JSP to get connection(from eclipse)

Bad practice, not recommended, why don't you use servlets ?
chetan dhumane wrote:
No suitable driver found-Urgent

http://faq.javaranch.com/java/EaseUp


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321


This topic is already been discussed more and more times in JDBC forum.. please use javaranch search utility before posting your query..

hope it helps.

Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Sagar Rohankar wrote:
Put those driver jar file on classpath.

This is certainly not a classpath issue, you would get a ClassNotFoundException otherwise, not a SQLException with the message "No suitable driver". You will get this exception when the driver isn't loaded at all, or the JDBC URL is plain wrong.

Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Bauke Scholtz wrote:
You will get this exception when the driver isn't loaded at all,

And it isn't loaded at because they aren't on classpath to load.
Bauke Scholtz wrote:
or the JDBC URL is plain wrong.

Yep, you got it right, the URL is wrong. The JDBC parameter/properties are separated by "&" and not by ";"
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Sagar Rohankar wrote:
And it isn't loaded at because they aren't on classpath to load.

As said, that would rather produce a ClassNotFoundException.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

Bauke Scholtz wrote:
Sagar Rohankar wrote:
And it isn't loaded at because they aren't on classpath to load.

As said, that would rather produce a ClassNotFoundException.


Yes, ClassNotFoundException occurs in Class.forName() statement and not in when connecting to DB

No suitable driver found for jdbc:mysql://localhost:3306/test?user=root;password=1234
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

OK, I got it, thanks Bauke and Balu. But what are the possible reasons for Driver not getting loaded?
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874



Though your intended Driver is in classpath , it will happen if your intended driver is not registered to DriverManager.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Sagar Rohankar wrote:OK, I got it, thanks Bauke and Balu. But what are the possible reasons for Driver not getting loaded?
It's either simply not loaded at all or he suppressed the exception.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Balu Sadhasivam wrote:
if your intended driver is not registered to DriverManager.

Right, when you say

then
When the method getConnection is called, the DriverManager will attempt to locate a suitable driver from amongst those loaded at initialization and those loaded explicitly using the same classloader as the current applet or application.(using Class.forName())

Crystal clear now
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: No suitable driver found
 
Similar Threads
Where to Place OracleDriver in WebSphere Test Environment for JSP page Development
unable to establish a connection betwen JDBC and MySQL server using a java class.
DB2 access from browser using JDBC
No suitable Driver in DB2
no suitable driver found jdbc:oracle:thin: