db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Burlison <Alan.Burli...@sun.com>
Subject Re: how to start database server from w/in java code
Date Mon, 31 Mar 2008 08:12:28 GMT
Brandon Dohman wrote:

> I’m going to be deploying a java desktop app, and I am curious on how to start the
database server from within the code.  I have done all of my testing through netbeans, and
have been able to get all of the connections and transactions to go smoothly, but the database
was started by using the tools > javadb > start db server option in netbeans.
> 
> With deployment, I’ll need to be able to start the code from within my java code.

See 
http://auth.opensolaris.org/svn/showfile.svn?path=%2ftrunk%2fAuthDb%2fsrc%2forg%2fopensolaris%2fauth%2fdb%2fDbManager.java&revision=HEAD&name=auth

----------
This class wraps the <a href="http://db.apache.org/derby/">Derby</a> 
database so that it is easy to start Derby and create a new database. 
It can be used to run Derby in one of three modes:

DbMode.EMBEDDED
The database runs embedded within the invoking JVM and is not externally 
accessible

DbMode.SERVER_EMBEDDED
The database runs within the invoking JVM as a network server and is 
externally accessible while the host JVM is running.

DbMode.SERVER_DAEMON
The database runs in a separate JVM as a network server and is 
externally accessible.  If the JVM that started the server exits, the 
Derby server will continue to run unless it is explicitly shut down.

In all the above cases, if the database does not exist when Derby is 
started, it will be created.  During creation the following three SQL 
scripts will be executed to create and populate the database, all held 
in the /sql directory in the library JAR file:

CONFIGURE_DB_SQL
Configure the database, e.g. create users and schemas, set permissions.

CREATE_DB_SQL
Create the database tables and indexes.

POPULATE_DB_SQL
Load any default values into the tables.
----------

-- 
Alan Burlison
--

Mime
View raw message