db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conor Moran (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-4931) Loading db from classpath or jars appears not to work
Date Tue, 07 Dec 2010 09:58:08 GMT

    [ https://issues.apache.org/jira/browse/DERBY-4931?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12968653#action_12968653
] 

Conor Moran commented on DERBY-4931:
------------------------------------

Yes your suggestion seems to work ....for both jars and file system...
Thanks a lot!

One surprise is that the connection is read-only for the filesystem db (I was only expecting
that for the jar)

BTW: Now what I'd like is to be able to do something like:
DriverManager.getConnection("jdbc:derby:memory:myInMemoryDB;createFrom=classpath:sweeping");

Any plans for supporting that kind of thing?




> Loading db from classpath or jars appears not to work
> -----------------------------------------------------
>
>                 Key: DERBY-4931
>                 URL: https://issues.apache.org/jira/browse/DERBY-4931
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.6.2.1
>         Environment: Windows 7
>            Reporter: Conor Moran
>
> When looking for duplicate issue before raising, I found DERBY-540 which was closed out
a while back - not sure if related
> I've tried many versions of loading db from both classpath and jar
> 1) From Classpath
>     connection = DriverManager.getConnection("jdbc:derby:directory:/myDb");
>     connection = DriverManager.getConnection("jdbc:derby:directory:myDb");
>     connection = DriverManager.getConnection("jdbc:derby:/myDb");
>     connection = DriverManager.getConnection("jdbc:derby:mtDb");
> 2) From jar on classpath
>     connection = DriverManager.getConnection("jdbc:derby:myDb");
>     connection = DriverManager.getConnection("jdbc:derby:/myDb");
>     connection = DriverManager.getConnection("jdbc:derby:memory:myDb");   //load from
classpath jar into memory
>     connection = DriverManager.getConnection("jdbc:derby:/myDb");                  //load
from classpath jar into memory
> 3) From non classpath jar - THESE WORK!!
>     connection = DriverManager.getConnection("jdbc:derby:jar:(C:/myDb.zip)myDb"); 
>     connection = DriverManager.getConnection("jdbc:derby:jar:(C:/myDb.zip)/myDb");  
       
> Unfortunately I couldn't get classpath based loading to work - I verified the zip was
on the classpath and successfully loaded resources from it using:
>  Thread.currentThread().getContextClassLoader.getResourceAsStream(....)
> Error stack trace is typically:
> java.sql.SQLException: Database 'myDb' not found.
> 	at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.handleDBNotFound(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
> 	at org.apache.derby.jdbc.Driver30.getNewEmbedConnection(Unknown Source)
> 	at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
> 	at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
> 	at java.sql.DriverManager.getConnection(DriverManager.java:572)
> 	at java.sql.DriverManager.getConnection(DriverManager.java:218)
> 	at com.s1.sweeping.persistence.jdbc.DerbyPersistorIntegrationTest.setUpOnce(DerbyPersistorIntegrationTest.java:27)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:618)
> 	at org.junit.internal.runners.ClassRoadie.runBefores(ClassRoadie.java:49)
> 	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:36)
> 	at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
> 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message