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(); } }
java sql database jdbc
Ice phoenix
source share