Derby and glassfish
The objective of this blog is to explain in detail the following.
- how javadb is closely integrated with
EE 5.0 SDK.
- how javadb is configured for better
out-of-the box experience.
- overview of how javadb is used
internally by SDK.
This blog is written using Java EE 5 SDK, the latest version can be
downloaded from http://java.sun.com/javaee/downloads/
Java EE 5 SDK all-in-one bundle was used to run through the examples
through application server commands
Javadb and EJBTimer
Javadb database and callflow
Using javadb tools
Javadb binaries are always installed
Installation root directory/javadb. The binaries include the
javadb core jar files,
useful javadb utilities(dblook, sysinfo and
ij) and a few a native scripts to perform functions like start, stop
database. The functionality
of start and stop scripts
are also available through application server command line interfaces.
domain and javadb database.
Every application server domain
created out of the
default installer as well as the ones explicitly created using 'asadmin
command will contain the following.
3.2.1. A javadb database to be used by EJBTimer
The name of this
database is 'ejbtimer
used to store information about EJB timers and is to be used by Timer
Service that is part of
this SDK. This database is owned by
the user owning the domain. The differences compared to J2EE 1.4 SDK
a). Pointbase database was
used for storing EJBTimer information.
b). The ejbtimer pointbase database
is owned by the user who initially performed the
installation, not by the owner of application server domain.
This database gets created under
<domainroot> by default will be
domain by name domain1 is
automatically created by SDK installer, 'ejbtimer' database is
run in "embedded mode
3.2.2. A JDBC connection pool by name "__TimerPool"
configured to point to 'ejbtimer' database. This pool is used by
3.2.3. A JDBC Resource with the jndi name of
that is configured to use __TimerPool.
3.2.4. A JDBC connection pool by name
configured to point to 'sun-callflow' database. This pool is used by
3.2.5. A JDBC Resource with the jndi name of
that is configured to use __CallFlowPool.
Entries 3.2.2 through and 3.2.5 can be viewed from SDK's powerful
administration console. From your browser, go to
to start the Administration Console, where <admin port> by
default will have 4848 unless changed during SDK installation process.
Log in with the administrator user name and password. After logging in
on the left hand side of the console, click to open
"Resources" to view the entries. (Timer related entries are circled in
the following image).
Alternatively, run 'asadmin
' to view the list of JDBC connection
pools and 'asadmin
' to view the list of of JDBC
have been created.
NOTE: None of these above components
deleted. Doing so will result in undesirable product behavior.
javadb through Application
Java EE 5 SDK's command line interface 'asadmin'
supports starting and stopping network server through 'asadmin
start-database' and 'asadmin
Prior to understanding what these
important to differentiate the two modes of javadb database
serverEmbedded and Network mode.
Refer to this link that has a very good
explanation of them. http://db.apache.org/javadb/papers/javadbTut/ns_intro.html
4.1 Starting javadb.
' command starts javadb
network server in shared mode to enable connections from other
hosts in network. By default javadb network server(engine)
requests from clients local to the machine.
Syntax: asadmin start-database [--dbhost 0.0.0.0] [--dbport 1527]
--dbhome specifies the root directory of the database to be created if
one is not specified, default is the current directory.
4.2 Stopping javadb.
0.0.0.0] [--dbport 1527]
--dbhost is the host name or ip address of the javadb database. The
default is the IP address 0.0.0.0, which listens on all interfaces.
--dbport can be used to start the javadb server process on a port other
5. Javadb database and EJB Timer.
Timer service provided by
SDK is used to schedule a timed
notification to happen at specific time, after a duration of time, or
intervals. This service uses javadb database to persist EJB timer
information. As mentioned in the previous section, a javadb database
created automatically as part of the application server domain
'ejbtimer' is used for data storage. SDK comes pre bundled with this
application to demonstrate how to
schedule timed notification of enterprise beans.
About the timer sample application.
TimerSessionEJB is a stateless session
bean that shows how to set a
timer. This application is installed under
convenience, this application similar to other sample applications is
also available as a
pre assembled app along with source code and the build environment.
The pre built ear file is used here rather than building the
application. However it is highly recommend to change the
application source and descriptors if required to understand
Deploying timer sample app to SDK.
-Change directory to
-Include SDKInstall/bin to PATH,
-Run 'asant deploy' will deploy the "timersession.ear"
file to the default domain(domain1).
-Run 'asadmin list-components' to verify the deployment.
Alternatively the deployment can also be verified
through "Administration Console"
Running the timer sample.
To run the application client, set your current directory to
the following command:
<SDKInstallDir>/bin/appclient -client timersessionClient.jar -xml
The output from the timer client is sent to
domain_root_dir/domain_name/server/logs/server.log. After about
you will see the following lines:
TimerSessionBean: start createTimer
For more info on this
Sample, Refer to the bundled samples documentation available in the
sample's Root directory.
Javadb database and
CallFlow enables monitoring of
application(s) behaviour that are
deployed in Application Server. When CallFlow is enabled(either through
Administration console OR
command line interfaces) a database by name 'sun-callflow' is created
<domainroot> by default will be
<SDKInstalllRoot>/domains. A default domain by name domain1 is
automatically created by SDK installer.
'sun-callflow' database is
run in "embedded mode
application server's JVM. All the runtime information about monitored
stored in this
database. This database if required can be cleared using Administration
Console. For more information on CallFlow please refer to CallFlow
Using javadb tools.
Javadb comes with a minimal set of
and they are ij, dblook and
sysinfo. SDK also includes several useful
scripts that can help you use javadb.
following scripts are available for use in the
startNetworkServer.ksh/bat — Script to start the network server
stopNetworkServer.ksh/bat — Script to stop the network server
ij.ksh/bat — interactive JDBC scripting tool
dblook.ksh/bat — Script to view all or part of the DDL for a database
sysinfo.ksh/bat — Script to display versioning info regarding the
NetworkServerControl.ksh/bat — Script which provides a means of
executing commands on the NetworkServerControl API
To Configure Your Environment to Run the javadb Utility Scripts,
following should be done
-Set the javadb_INSTALL environment variable to the
-Unset your CLASSPATH environment variable.
-You can also optionally set the following properties:
javadb_SERVER_HOST to the host on which the network server will listen.
Can also be set to 0.0.0.0 to enable all listeners.
javadb_SERVER_PORT to the port number on which the network server will
8. Some useful Links.