Sunday Nov 09, 2008

Java DB and GlassFish v3 Prelude

GlassFish v3 Prelude launched recently and bundles Java DB, Sun's supported version of Apache Derby.

As you may already know, GlassFish v3's foundations are based on HK2, some Hundred Kilobytes Kernel with a module subsystem and component model that can run on top of OSGI.

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 --
derby.drda.traceDirectory=C:\\Apps\\glassfishv3-prelude\\glassfish...
derby.drda.maxThreads=0
derby.drda.keepAlive=true
derby.drda.minThreads=0
derby.drda.portNumber=1527
derby.drda.logConnections=false
derby.drda.timeSlice=0
derby.drda.startNetworkServer=false
derby.drda.host=0.0.0.0
derby.drda.traceAll=false
.......................................

Now, that GlassFish and Java DB have been started, you can test a ping connection via the GlassFish Administration console at:
http://localhost:4848/

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
> javadb\\frameworks\\NetworkServer\\bin\\ij
> ij version 10.2
   ij> connect 'jdbc:derby://localhost:1527/sun-appserv-samples;user=APP;password=APP';
   ij> select count(\*) COUNT from sys.systables;
        COUNT
        -----------
        19
   ij> exit;

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.

Wednesday Jul 30, 2008

SNCF rides on GlassFish and Java DB


As Alexis Moussine-Pouchkine posted on this blog, the French railways company, SNCF uses GlassFish and Java DB (based on Apache Derby) to power a monitoring application which produces alerts with a real-time graphical representation of key system variables as well as PDF reports.

Don't miss this questionnaire with Franck LeprĂȘtre, Software Architect at SNCF.

Java DB version 10.2.2.0 is bundled in Glassfish V2.

About

forsini

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
Bookmarks