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







Reply via email to