From derby-user-return-7902-apmail-db-derby-user-archive=db.apache.org@db.apache.org Thu Oct 25 20:03:50 2007 Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 7232 invoked from network); 25 Oct 2007 20:03:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Oct 2007 20:03:50 -0000 Received: (qmail 21726 invoked by uid 500); 25 Oct 2007 20:03:36 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 21706 invoked by uid 500); 25 Oct 2007 20:03:36 -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 21695 invoked by uid 99); 25 Oct 2007 20:03:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Oct 2007 13:03:36 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [130.209.16.101] (HELO hillhead.cent.gla.ac.uk) (130.209.16.101) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Oct 2007 22:04:22 +0000 Received: from lenzie.cent.gla.ac.uk ([130.209.16.18]) by hillhead.cent.gla.ac.uk with esmtp (Exim 4.10) id 1Il8vF-0002w7-00 for derby-user@db.apache.org; Thu, 25 Oct 2007 21:03:17 +0100 Received: from vpn7.dcs.gla.ac.uk ([130.209.254.7]) by lenzie.cent.gla.ac.uk with esmtp (Exim 4.50) id 1Il8vF-0003do-Bi for derby-user@db.apache.org; Thu, 25 Oct 2007 21:03:17 +0100 Mime-Version: 1.0 (Apple Message framework v752.2) Content-Transfer-Encoding: 7bit Message-Id: <78ABD5A3-E665-4F68-8A6C-41D37367E38E@bio.gla.ac.uk> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: Derby Discussion From: David Leader Subject: Including a derby database in a Windows executable (was Can the derby.log file be suppressed?) Date: Thu, 25 Oct 2007 21:03:29 +0100 X-Mailer: Apple Mail (2.752.2) X-Virus-Checked: Checked by ClamAV on apache.org Changing the topic I wrote: > Now, does anyone know how to include a derby database in a > Windows .exe file? > and John Embretsen replied > If your database is read-only, I guess you could put your database > in a jar (your application jar file) and the wrap the jar in an exe > file > You can read about putting the DB in a jar in the Derby Developer's > Guide, within the section "Creating Derby databases for read-only > use". Thanks John. I tried that last summer when we were first playing with derby, and I gave up as I was unable to find a path to the database. I've just tried again, with similar results. So, either it's not possible or I'm doing it wrong. Let me describe my setup. 1. DB external to the jar file (Database name: DihedralizerDB) String url = "jdbc:derby: DihedralizerDB" connection code for Connection conn: Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); conn = DriverManager.getConnection(url); OK. Now for the tough stuff: 2. DihedralizerDB as a directory within the jar file at the same level as the main method. (I've inspected the jar file with one of the available gui tools, so I know the structure is as I say it is.) I reference other directories containing image files and text files within the jar file ok, so I know how to include these and normally specify directory/filename. But clearly that will not work here. How do I reference the database? The Derby Developer's Guide instructions for referencing a database within a jar file has: jdbc:derby:jar:(pathToArchive)databasePathWithinArchive but what is the path to the archive if it's in the same jar file as the main class? '.' ? './' ? Neither of these work for me with the path to the db specified as just the name of the db. The examples are not very helpful as they give absolute paths from someone's C drive, so presumably are for an external zipped or archived file (which I did manage to get to work just as a check). jdbc:derby:jar:(C:/dbs.jar)products/boiledfood jdbc:derby:jar:(C:/dbs.jar)sales i.e. I have no joy with jdbc:derby:jar:(./)DihedralizerDB or jdbc:derby:jar:(/)DihedralizerDB or most other variants I can think of. Can it be done? David