db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Ehmann <behmannl...@gmail.com>
Subject Re: unable to access DB on classpath
Date Tue, 29 Aug 2006 15:10:00 GMT
andersmo in the #derby irc room figured this out for me:

First, when jar-ing a db directory it was necessary to jar from one  
level up and not the db directory itself.  For example, if the db,  
named myDB, is in /data/myDB, it is necessary to jar the /data  
directory.
Next, set the jar containing the db on the classpath and connect to  
it using the following connection string:
'jdbc:derby:classpath:myDB'

Thanks again andersmo.

On Aug 29, 2006, at 8:59 AM, Brian Ehmann wrote:

> Hey everyone,
>
> First, forgive me if this is a dumb question, but I can't seem to  
> find the answer in the derby documentation.
>
> I am developing a web app on tomcat that uses container managed  
> security and I would like to migrate the authentication data from  
> mysql to an embedded derby db.  I have created the DB, using ij, as  
> follows:
>
> driver 'org.apache.derby.jdbc.EmbeddedDriver';
> connect 'jdbc:derby:AerosmithDB;create=true';
> create table users (username varchar(15) not null primary key,  
> password varchar(35) not null);
> create table userroles ( username varchar(15) not null, role varchar 
> (15) not null, primary key (username, role));
> insert into users(username, password) values ('test', 'test');
> insert into userroles(username, role) values ('test',  
> 'registereduser');
> commit;
> disconnect;
>
> I then jar the "AerosmithDB" directory into a jar and place it on  
> the classpath.  Unfortunately, using ij, I am not able to connect  
> to the database that is on the classpath.  See below:
>
> $ echo $CLASSPATH
> /Users/brian/src/eclipse/workspace/Aerosmith/WebContent/WEB-INF/ 
> AerosmithDB.jar:/Developer/Java/db-derby-10.1.3.1/lib/derby.jar:/ 
> Developer/Java/db-derby-10.1.3.1/lib/derbytools.jar
> $ ij
> ij version 10.1
> ij> driver 'org.apache.derby.jdbc.EmbeddedDriver';
> ij> connect 'jdbc:derby:/AerosmithDB';
> ERROR XJ004: Database '/AerosmithDB' not found.
> ij> connect 'jdbc:derby:AerosmithDB';
> ERROR XJ004: Database 'AerosmithDB' not found.
> ij> connect 'jdbc:derby:classpath:/AerosmithDB';
> ERROR XJ004: Database 'classpath:/AerosmithDB' not found.
> ij> connect 'jdbc:derby:classpath:AerosmithDB';
>
> Any ideas?
>
> Thanks,
>
> Brian


Mime
View raw message