Wednesday Dec 10, 2008

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> 

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