I\'ve followed the JDBC tutorial at: http://docs.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html, and managed to build and create my own JDBC database without too
You said you have followed the tutorial. In the tutorial you had to install JDBC driver.
Installing a JDBC driver generally consists of copying the driver to your computer, then adding the location of it to your class path.
After installing the driver you run
java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver
That is only possible if you messed the correct diver.
You have used
org.apache.derby.jdbc.EmbeddedDriver
to load the driver
but should use
org.apache.derby.jdbc.ClientDriver
I have been putting any needed jdbc driver at for example in the jre\lib\ext directory. On my system that would be: X:\Java\jre1.8.0_181\lib\ext Hope that helps.
I was getting the java.lang.ClassNotFoundException upon using the ClientDriver. I used the latest Driver binaries, and that was the mistake.
At that time, the latest Driver binary was 10.15.1.3, right here: Apache Site
I'm on Java 8, and I use the Hibernate 5.4.2.Final. Yet, the driver is compiled against the Java 9!
See the "Set DERBY_INSTALL" and "Configure Embedded Derby" section at https://db.apache.org/derby/papers/DerbyTut/install_software.html#derby_configure for details.
Derby is part of the JavaSE installation and I had setup 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
Java JDK comes with both
org.apache.derby.jdbc.EmbeddedDriver
org.apache.derby.jdbc.ClientDriver
Within eclipse add the following jars to the used JRE(JDK) or explicitly to your project.
[JDK]db/lib/derby.jar (EmbeddedDriver)
[JDK]db/lib/derbyclient.jar (ClientDriver)
For runtine you needed to made the appropriates jar available for your java application.
I found recently that if you are using jlink
to create a runtime, you may need to include additional jdk modules to allow the driver to instantiate.
In my case I needed to include the java.naming
and java.management
modules within the image.