Reputation: 251
I am trying to retrieve data installed on the database server JAVA DB located in jdk1.7.0_06. I am able to make connection to the server and create the database. But i am getting following error for the compilation and running:
No suitable driver found for jdbc:derby:AddressBook
Please can you help me! Thank you
Upvotes: 1
Views: 381
Reputation: 285402
I stated, "I wonder if you need to set the derby.system.home
property as the Java DB tutorials suggest. Have you tried this? Something like, System.setProperty("derby.system.home", DERBY_HOME_PATH);
where the second parameter is the path to your database's home directory."
And you replied:
@HovercraftFullOfEels, i think i didn't but i am sure that i have set some envariable variables via command line.
@Dorji: that doesn't set the System properties in your JVM though. I still think that you need to set this property before using your database. For example,
public class Test {
public static final String DERBY_HOME = "derby.system.home";
// ***** the two Strings below will be different for you *****
public static final String DERBY_HOME_PATH = "D:/DerbyDB";
private static final String DB_NAME = "sample";
public static void main(String[] args) {
System.setProperty(DERBY_HOME, DERBY_HOME_PATH);
Connection conn = null;
try {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
conn = DriverManager.getConnection("jdbc:derby:" + DB_NAME);
} catch (InstantiationException | IllegalAccessException
| ClassNotFoundException | SQLException e) {
e.printStackTrace();
} finally {
if (conn == null) {
System.exit(-1);
}
}
// .... etc...
My derby.system.home directory is D/:DerbyDB, and my database resides in the D/:DerbyDB/sample directory:
This of course will be different for you.
Upvotes: 2