Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

java.sql.SQLException: No suitable driver found

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have installed jdk 11.0.8 and mysql. As per my knowledge i have also included the connector jar file in the classpath but when i'm trying to run the test code to check connectivity is shows this error.
java.sql.SQLException: No suitable driver found
       at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702)
       at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
       at jdbctest.main(jdbctest.java:10)
 
Saloon Keeper
Posts: 242
39
Firefox Browser MySQL Database Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, and welcome to the Ranch!

Could you post the code you're running to test the connection? Also, how are you running it?
 
Tanuj Bhatt
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is code which i used to test:


Also i now able to run the connection after changing all the path to jdk 1.8 but still i want to know how to run the mysql connection in jdk 11 and higher as per i know they don't have a separate jre folder to put connector jar file
 
Ranch Hand
Posts: 5397
1
Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tanuj Bhatt wrote:
Also i now able to run the connection after changing all the path to jdk 1.8 but still i want to know how to run the mysql connection in jdk 11 and higher as per i know they don't have a separate jre folder to put connector jar file



May be JDK11 and higher needs different MySQL driver file.

But its sad if Oracle is not maintaining backward compatibility.
 
Saloon Keeper
Posts: 22678
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tanuj Bhatt wrote:this is code which i used to test:

Also i now able to run the connection after changing all the path to jdk 1.8 but still i want to know how to run the mysql connection in jdk 11 and higher as per i know they don't have a separate jre folder to put connector jar file



We REALLY need to see how you are trying to execute that application. NO version of Java should have been able to locate a JDBC driver just because you drop it into a JDK or JRE directory, since all Java code in the Java VM directories is secured by Oracle and anything else will be rejected. That's a security feature that goes all the way back to Java 1.0.

If you are running the app under an IDE environment we need to know what IDE you're using and some idea of how the project was set up. If you are trying to run the app directly on the command line, we need to see the actual command you are typing uin.
 
Marshal
Posts: 25968
70
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:NO version of Java should have been able to locate a JDBC driver just because you drop it into a JDK or JRE directory...



Well, no. The OP apparently dropped the driver into the extensions directory in the past, a feature with its pros and cons. Personally I got burned by it a couple of times -- for example if you move your application to a different system or upgrade to a new JRE (as in this thread) you have to make sure you copy your "extension" over into the new system's extensions directory. Which you will probably forget to do because you forgot you dropped it there in the first place.

It's true that the later versions of the JRE don't have an "ext" directory under the "lib" directory. Whether you could just create your own and carry on, or whether the extensions directory has been discontinued, I don't know. But I would recommend just putting the JDBC driver in the classpath -- everybody should know how to set up their classpath anyway.
 
Tanuj Bhatt
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:We REALLY need to see how you are trying to execute that application.


I'm running in cmd with the class path set in environment variables.

Paul Clapham wrote:
It's true that the later versions of the JRE don't have an "ext" directory under the "lib" directory. Whether you could just create your own and carry on, or whether the extensions directory has been discontinued, I don't know. But I would recommend just putting the JDBC driver in the classpath -- everybody should know how to set up their classpath anyway.


I did attach the path to the folder also the classpath to the driver but now I know the error, I forgot to put ';' :-D.

Error is resolved now. Thanks guys for your inputs.
 
Then YOU must do the pig's work! Read this tiny ad. READ IT!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic