• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

No suitable driver found

 
Ranch Hand
Posts: 643
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I got it, thanks Bauke and Balu. But what are the possible reasons for Driver not getting loaded?
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Though your intended Driver is in classpath , it will happen if your intended driver is not registered to DriverManager.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic