By forsini on Nov 09, 2008
Java DB modular architecture is similarly based on modules and services components and can also run as an OSGI bundle. Both GlassFish and Java DB can run embedded in some Java framework or as standalone applications in their own JVM process.
I thought I would highlight how you can get Java DB running in one command and start using it. Note that there is no change as far as how Java DB is run with previous versions of GlassFish.
To start a GlassFish server instance:
\*\* Hint: First make sure to set JAVA_HOME environment variable to point to Sun JDK6 root installation directory.
> cd glassfishv3-prelude (or wherever directory you have installed GlassFish)
> bin\\asadmin start-domain (to start the default domain instance)
Then all you have to do to start Java DB as a standalone server process is:
> bin\\asadmin start-database
Database started in Network Server mode on host 0.0.0.0 and port 1527.
--------- Derby Network Server Information --------
Version: CSS10020/10.2.2.1 - (538595) Build: 538595 DRDA Product Id: CSS10020
-- listing properties --
Now, that GlassFish and Java DB have been started, you can test a ping connection via the GlassFish Administration console at:
Navigate to Resources> JDBC> Connection Pools> DerbyPool
which is a pre-defined sample JDBC connection pool.
You will be able to ping the running Java DB instance by clicking on the Ping button.
It will create some sun-appserv-samples GlassFish sample database by default under glassfishv3-prelude\\glassfish\\databases directory and derby.log will also be under that same location.
That's it. You can now access the sample database via the JDBC sample DerbyPool connection pool from your application.
You could also connect via IJ, Java DB's command-line tool as follows:
> set DERBY_INSTALL=C:\\glassfishv3-prelude\\javadb
> cd glassfishv3-prelude
> ij version 10.2
ij> connect 'jdbc:derby://localhost:1527/sun-appserv-samples;user=APP;password=APP';
ij> select count(\*) COUNT from sys.systables;
To stop Java DB, simply run:
> bin\\asadmin stop-database
Connection obtained for host: 0.0.0.0, port number 1527.
Apache Derby Network Server - 10.2.2.1 - (538595) shutdown at 2008-11-09 08:48:43.312 GMT
Command stop-database executed successfully.
More information about GlassFish's admin start-database and stop-database commands.