Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLException: No suitable driver found for jdbc:derby://localhost:1527

Tags:

java

jdbc

derby

I get this error in Netbeans:

java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/

How is this caused and how can I solve it?

like image 661
Ganesh Avatar asked Sep 28 '10 18:09

Ganesh


3 Answers

java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/

This exception has two causes:

  • The driver is not loaded.
  • The JDBC URL is malformed.

In your case, I'd expect to see a database name at the end of the connection string. For example (use create=true if you want the database to be created if it doesn't exist):

jdbc:derby://localhost:1527/dbname;create=true

Databases are created by default in the directory where the Network Server was started up. But you can also specify an absolute path to the database location:

jdbc:derby://localhost:1527//home/pascal/derbyDBs/dbname;create=true

And just in case, check that derbyclient.jar is on the class path and that you are loading the appropriate driver org.apache.derby.jdbc.ClientDriver when working in server mode.

like image 107
Pascal Thivent Avatar answered Oct 19 '22 14:10

Pascal Thivent


Notice: you can download it from here.

If you can't find it, then

  1. Find your project in projects selection tab

  2. Right click "Libraries"

  3. Click "Add JAR/Folder..."

  4. Choose "derbyclient.jar"

  5. Click "Open", then you will see "derbyclient.jar" under your "Libraries"

Make sure your URL, user name, password is correct, and run your code:)

like image 44
Devy Avatar answered Oct 19 '22 16:10

Devy


For me

DriverManager.registerDriver(new org.apache.derby.jdbc.EmbeddedDriver());

helped. In this way, the DriveManager does know the derby EmbeddedDriver. Maybe allocating a new EmbeddedDriver is to heavy but on the other side, Class.forName needs try/catch/doSomethingIntelligentWithException that I dont like very much.

like image 11
Bruno Eberhard Avatar answered Oct 19 '22 15:10

Bruno Eberhard