Hello, I'm using NetBeans 6.7.1, and Derby 10.5.3.0. I'm trying to learn how to write Database applications, and I'm having trouble connecting to my Database. It loads the Derby Driver (EmbeddedDriver), but won't connect to the the Database named test. I looked at tests Properties in NetBeans, and it said that it was using the org.apache.jdbc.derby.ClientDriver. I did create the Database, and give it no username or password. Below is the code that I have. If anybody could help, that would be great =D
package jdb.test;
import java.sql.*;
public class DatabaseTest {
public static void main(String[] args){
try{
// Load the EmbeddedDriver class
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
System.out.println("Loaded Derby Driver");
}catch(Exception e){
e.printStackTrace();
System.out.println("Error loading Derby Driver. Shutting down.");
System.exit(-1);
}
// The database located on my computer
String database = "jdbc:derby://localhost:1527/test";
try{
// Connect without a username and password
Connection conn = DriverManager.getConnection(database);
System.out.println("Connected to "+database);
}catch(SQLException e){
e.printStackTrace();
System.out.println("Could not connect to "+database);
System.exit(-1);
}
System.out.println("You have connect to the selected database.");
}
}
This is the error that I get:
java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/test
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:207)
at jdb.test.DatabaseTest.main(DatabaseTest.java:22)