Java DB as a service on OpenSolaris 2008.11

The recently released OpenSolaris 2008.11 comes with Java DB 10.4.2.1. One of the new features compared to the Java DB version in OpenSolaris 2008.05 is support for SMF (Service Management Facility). Now it's very easy to start a Java DB Network Server and make it run as a service. SMF takes care of starting and stopping the server when the computer is booted or shut down. It will even attempt to restart the server process if it crashes. To enable the Java DB service, make sure the Java DB package is installed and then enable the service with svcadm(1M):

kah@opensolaris:~ % pfexec pkg install SUNWjavadb
...
kah@opensolaris:~ % svcadm enable javadb

Now check the status of the service. It should be online:

kah@opensolaris:~ % svcs -xv javadb
svc:/application/database/javadb:default (Java DB)
 State: online since Wed Dec 10 14:35:53 2008
   See: http://developers.sun.com/javadb/
   See: /var/svc/log/application-database-javadb:default.log
Impact: None.

Configuration options may be changed with svccfg(1M). For example, if you want the Java process in which the server is running to be started with -server -Xmx1024M, do this:

kah@opensolaris:~ % svccfg
svc:> select javadb
svc:/application/database/javadb> setprop javadb/java_args=("-server" "-Xmx1024M")
svc:/application/database/javadb> quit
kah@opensolaris:~ % svcadm refresh javadb
kah@opensolaris:~ % svcadm restart javadb

And finally, use ij to connect to the server:

kah@opensolaris:~ % java -jar /opt/SUNWjavadb/lib/derbyrun.jar ij
ij version 10.4
ij> connect 'jdbc:derby://localhost:1527/MyDB;create=true';
ij> select count(\*) from sys.systables;
1          
-----------
20         

1 row selected
ij> 

Comments:

This example also teaches us how to use SMF!

In what kind of apps do you think this facility would be most useful?

Thanks.

Posted by M. Mortazavi on December 10, 2008 at 11:07 PM CET #

I find SMF useful for all kinds of services that you have running on your machine, not limited to network servers, but also tasks that you want to be performed on startup and shutdown, like mounting the file systems, setting up the network and starting X. What's unique about SMF is not so much that you can start and stop services easily, but rather that monitoring, reconfiguration and logging is done in a uniform way for all the services on your system, which makes system maintenance much easier.

Posted by Knut Anders Hatlen on December 11, 2008 at 03:33 AM CET #

Post a Comment:
Comments are closed for this entry.
About

kah

Search

Categories
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