• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No suitable driver found for jdbc connection.

 
Shubham Semwal
Ranch Hand
Posts: 176
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm getting error - No suitable driver found for No suitable driver found for jdbc:mysql:thin:@localhost/jdbcdemo



I'm using eclipse. I have "mysql-connector-java-5.1.21.jar" added as referenced libraries.

Database name - jdbcdemo
Table name - students.
 
Claude Moore
Ranch Hand
Posts: 828
7
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please verify if the connection url you used in the connection string is valid for MySQL. JDBC (4.0 ? not sure if the same applies to previous versions as well) checks if there is a driver accepting a given connection url.
 
Shubham Semwal
Ranch Hand
Posts: 176
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Connection con = DriverManager.getConnection("jdbc:mysql:thin://localhost/jdbcdemo","root","");

No idea what is being done here. I've installed wamp server and created db there. My database name is jdbcdemo.
MySQL version - 5.6.12

profile being used in MySQL : Username - root password -"".
 
Tim Moores
Bartender
Posts: 3128
50
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
+1 on what Claude said - the "thin:" part looks fishy. Where did you get that from?
 
Shubham Semwal
Ranch Hand
Posts: 176
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I removed "thin". Now its working but I'm super confused.
I gues I mixed syntaxes for OracleDB and Mysql :
Oracle : jdbc: oracle:thin:@localhost:1521:xe
MySQL : jdbc:mysql://localhost/jdbcdemo

I thought "thin" is used for a driver. Why aren't we using that in MySQL syntax ?
 
Tim Moores
Bartender
Posts: 3128
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "thin" part is an Oracle thing; it does not apply to MySQL. Actually, the entire part after the 2nd colon is specific to the driver, so there's a lot of variety.
 
Shubham Semwal
Ranch Hand
Posts: 176
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot @tim and @claude
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic