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 much fuss. However now when trying to connect to the database from a java application I'm receiving the exception:
java.sql.SQLException: No suitable driver found for jdbc:derby:db directory
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 positive that that driver should have no issues loading as that is the driver specified in the tutorial and it had no issues creating the database using that driver. I've event tried adding the property " ;create=true" at the end of the connection statement to try and create a brand new database but I still receive the same exception error.
Please see my application 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();
}
}