Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 91060 invoked from network); 6 Apr 2006 10:23:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Apr 2006 10:23:15 -0000 Received: (qmail 92593 invoked by uid 500); 6 Apr 2006 10:23:03 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 92377 invoked by uid 500); 6 Apr 2006 10:23:02 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 92366 invoked by uid 99); 6 Apr 2006 10:23:02 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Apr 2006 03:23:02 -0700 X-ASF-Spam-Status: No, hits=0.3 required=10.0 tests=MAILTO_TO_SPAM_ADDR X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [213.208.108.44] (HELO das01.DAS.local) (213.208.108.44) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Apr 2006 03:23:02 -0700 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: Storing/Accessing a Derby database inside a JAR X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Date: Thu, 6 Apr 2006 11:24:14 +0100 Message-ID: <79CBD9C7DAEEF7499CBD13C913D251C60A04D1@das01.DAS.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Storing/Accessing a Derby database inside a JAR Thread-Index: AcZXR3j9I3dzs7tUQpq0qM6R23SykwCHJcEQ From: "Rhys Campbell" To: "Derby Discussion" X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi, I've use getResource() to access images and text files contained within jar files. Maybe this will work for Derby databases? http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ClassLoader.html#getRe source(java.lang.String)=20 -----Original Message----- From: Susan Cline [mailto:home4slc@pacbell.net]=20 Sent: 03 April 2006 18:44 To: Derby Discussion Subject: Re: Storing/Accessing a Derby database inside a JAR Hi Daniel, I have not tried this myself, but looking at the documentation=20 and looking at the error I wonder if the the path to the database=20 from within the jar file is correct. Please see my specific comments below. Susan --- Daniel Morton wrote: [ snip ] >=20 > I created a jar using: >=20 > jar cf NameGenerator.jar djm NameDB >=20 > so that the database, and the NameGenerator class in > the djm package is put in to the jar. However, if I > run a test.java program to create a NameGenerator > object, it errors when trying to connect to the > database: SQLException: Database '/NameDB' not found. >=20 > My connection string (per the Derby Documentation) is: > DriverManager.getConnection("jdbc:derby:/NameDB"); > I've tried multiple varitions on this (ie. NameDB, > /NameDB, /NameDB/ etc.) >=20 > And in the above, the NameGenerator.jar is in the > classpath. I believe trying to access the database this way will not work as per the documentation, you need to use the jdbc:derby:jar syntax as you have below. >=20 > I've also tried specicifying the explicit path (ala > the Derby Manual): > DriverManager.getConnection("jdbc:derby:jar:(C:/project/NameList/NameGen erator.jar)/NameDB"); >=20 > Which results in the SQLException: Failed to start > database > 'jar:(C:/project/NameList/NameGenerator.jar)/NameDB' > Java Exception: The system cannot find the file > specified: java.util.zip.ZipException. This error looks more hopeful :-) At least it is looking for the /NameDB in the jar file. But I'm thinking that the path to the NameDB relative to the jar file is the problem. When you "unjar" the NameGenerator.jar file what is the path to NameDB? What happens if you try this URL instead; 'jar:(C:/project/NameList/NameGenerator.jar)NameDB' >=20 [ snip ] > Also, once I get this > sorted out, is there a way to include derby.jar inside > NameGenerator.jar so that just the one file could be > distributed? >=20 I don't know the answer to this, but it seems like it might be tough since it would be a chicken-and-egg situation. In=20 order to use the Derby JDBC connection URL it would need to have derby.jar in the classpath first. Hopefully someone else can help you with this one.