db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Fitzgerald <dfitzgeral...@sympatico.ca>
Subject Can't find derby embedded driver when calling class is in a jar file
Date Sat, 21 Jan 2006 20:21:13 GMT
Hi people, I have a class which does the usual : i.e.

String dbc="org.apache.derby.jdbc.EmbeddedDriver";
String url="jdbc:derby:C:\\PersistenceStore;create=true";
<<store them into a properties file db_pr >>

    private Connection openConnection() {
        Connection c = null;
        try {

            c = DriverManager.getConnection(db_pr.getProperty("url"), 
db_pr.getProperty("uid"), db_pr.getProperty("pwd"));
        } catch (IllegalAccessException iae) {
            logException(iae, getClass().getName(), 6000);
        } catch (ClassNotFoundException cnfe) {
            logException(cnfe, getClass().getName(), 6005);
        } catch (InstantiationException ie) {
            logException(ie, getClass().getName(), 6010);
        } catch (SQLException se) {
            while (se != null) {
                logException(se, getClass().getName(), 6015);
                se = se.getNextException();
        return c;

I have the derby jar files set in the classpath. This code has always 
worked fine from any programs run from the command line but when I 
package the code above into a jar file, it can't find the embedded 
driver for Derby anymore, although the code works fine with Oracle DB 
7.x, Sybase etc. I tried to set the jar files as run-time parameters as :

java -cp .;./derby.jar program.jar or
java -cp %classpath% program.jar

to no avail.

Can anyome tell me what I have to do to get this to work ?
Regards, Dan

View raw message