You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by cdwillie76 <ch...@gmail.com> on 2007/11/07 19:36:33 UTC

Using embedded derby with JRuby and Rails

Anyone configured Derby with the embedded JDBC driver with JRuby/Rails as a
war file deployment?  I have successfully using Derby in client/server mode
with a JRuby/Rails war deployment.  But since this database is pretty small
and low bandwidth, I would like to just combine it in to the same war
deployment as my rails application.  Any suggestions on how one would go
about this would be great.

Thanks
Chris
-- 
View this message in context: http://www.nabble.com/Using-embedded-derby-with-JRuby-and-Rails-tf4766517.html#a13633097
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Re: Using embedded derby with JRuby and Rails

Posted by Alan Burlison <Al...@sun.com>.
David Van Couvering wrote:

> You could do this by running some JDBC that does this, or you can
> include in your application jar a copy of the database directory, and
> extract this into the proper location when the application starts up.

Or you could script it in SQL files and then run them via ij, which can 
be found in derbytools.jar, and can be embedded into your app.

See 
http://src.opensolaris.org/source/xref/website/auth/trunk/AuthDB/src/org/opensolaris/auth/db/DbManager.java 
for an example - search for 'ij.runScript'.

-- 
Alan Burlison
--

Re: Using embedded derby with JRuby and Rails

Posted by David Van Couvering <da...@vancouvering.com>.
In terms of how you change your application, in general all you should
need to do is change the URL to be "jdbc:derby:dbname" from
"jdbc:derby:/server:port/dbname"

However, when you embed a database, the database is created based at
the location given by the Java system property  "derby.system.home"
or, if that's not present, the value of the Java system property
"user.dir".  What this usually means is that when your application
starts up, you need to take care of initializing the database if it
doesn't exist.  That includes creating the tables and loading initial
data.

You could do this by running some JDBC that does this, or you can
include in your application jar a copy of the database directory, and
extract this into the proper location when the application starts up.

David

On Nov 7, 2007 10:36 AM, cdwillie76 <ch...@gmail.com> wrote:
>
> Anyone configured Derby with the embedded JDBC driver with JRuby/Rails as a
> war file deployment?  I have successfully using Derby in client/server mode
> with a JRuby/Rails war deployment.  But since this database is pretty small
> and low bandwidth, I would like to just combine it in to the same war
> deployment as my rails application.  Any suggestions on how one would go
> about this would be great.
>
> Thanks
> Chris
> --
> View this message in context: http://www.nabble.com/Using-embedded-derby-with-JRuby-and-Rails-tf4766517.html#a13633097
> Sent from the Apache Derby Users mailing list archive at Nabble.com.
>
>