JDBC Derby driver not found

I followed the JDBC tutorial at http://docs.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html and I managed to create and create my own JDBC database without too much fuss. However, now when I try to connect to the database from a Java application, I get an exception:

java.sql.SQLException: No suitable driver found for jdbc: derby: db Catalog

Then, when trying to manually specify the JDBC driver, using:

Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); 

I get the following exception error:

java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver

I am sure that this driver will not have problems with loading, since it is the driver specified in the tutorial, and it had no problems creating a database using this driver. I tried adding the property "; create = true" at the end of the connection statement to try to create a new database, but I still get the same exception error.

See my app code below. Any help at all would be fantastic :).

 package com.ddg; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class SQLConnect { Connection Conn = null; String URL; String Username; String Password; public SQLConnect() { try { Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); } catch (ClassNotFoundException e) { System.out.println(e.toString()); } URL = "jdbc:derby:*directory name*"; System.out.println("Created SQL Connect"); } public void CreateConnection() { try { Conn = DriverManager.getConnection(URL); System.out.println("Successfully Connected"); } catch (SQLException e) { System.out.println(e.toString()); } } public void CloseConnection() { try { this.Conn.close(); System.out.println("Connection successfully closed"); } catch (SQLException e) { System.out.println(e.toString()); } } public static void main(String args[]) { SQLConnect sql = new SQLConnect(); sql.CreateConnection(); sql.CloseConnection(); } } 
+8
java sql database jdbc
source share
7 answers

java.sql.SQLException: No suitable driver found for jdbc: derby: db Catalog

So your error could be caused by:

The driver is not loaded correctly or your URL faulty. So first you need to make sure your *.jar is in the classpath. Check this.

Also try changing the URL to:

 jdbc:derby://<path>/<databasename>;create=true 

create=true ensures that db will be created if it does not exist.

Update:

Look at this thead also: SQLException: No suitable driver found for jdbc: derby: // localhost: 1527

+10
source share

If you have this type of error

 java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver 

and you are using netbeans , then you must follow these steps:

  • right click on library
  • select the option to add a library and from the list of libraries select "Java DB Driver"

enter image description here

+3
source share

You said you were following the textbook. In the tutorial, you needed to install the JDBC driver.

Installing a JDBC driver usually consists of copying the driver to your computer, and then add it to your class path.

After installing the driver, you run

 java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver 

This is only possible if you ruined the right diver.

You used

 org.apache.derby.jdbc.EmbeddedDriver 

for driver download

but should be used

 org.apache.derby.jdbc.ClientDriver 
+2
source share

Java JDK comes with both

 org.apache.derby.jdbc.EmbeddedDriver org.apache.derby.jdbc.ClientDriver 

Within eclipse, add the following jars to your JRE (JDK) or explicitly to your project.

 [JDK]db/lib/derby.jar (EmbeddedDriver) [JDK]db/lib/derbyclient.jar (ClientDriver) 

For runtine, you needed to make a suitable jar available for your java application.

+2
source share

For more information, see the section “Install DERBY_INSTALL” and “Configure Embedded Derby” at https://db.apache.org/derby/papers/DerbyTut/install_software.html#derby_configure .

Derby is part of the JavaSE installation, and I had the DERBY_HOME environment variable DERBY_HOME instead of DERBY_INSTALL shown in the link.

 C:\> set DERBY_HOME=c:\Program Files\Java\jdk1.8.0_60\db C:\> set CLASSPATH=%DERBY_INSTALL%\lib\derby.jar;%DERBY_INSTALL%\lib\derbytools.jar;. C:\> cd %DERBY_INSTALL%\bin c:\Program Files\Java\jdk1.8.0_60\db\bin> setEmbeddedCP.bat 
+1
source share

I put any necessary jdbc driver, for example, in the jre \ lib \ ext directory. On my system, it will be: X: \ Java \ jre1.8.0_181 \ lib \ ext I hope this helps.

0
source share

I was getting java.lang.ClassNotFoundException exception when using ClientDriver . I used the latest drivers and it was a mistake.

At that time, the last driver binary was 10.15.1.3, right here: Apache Site

I am on Java 8 and I am using Hibernate 5.4.2.Final. However, the driver compiled with Java 9!

0
source share

All Articles