JDBManager Example

The following is an example of checking out and running a simple JDBManager example program. We will run jReadDB.java, which reads data from the CMPCHEL data table into a list of CmpChEl components.

  1. Create a new SRT development directory, add JDBManager and DBUtils packages to it. In this example I am calling it 'test2'.
    cdfsga:/spool/dbox% newrel -t development test2
    Creating a test release "test2" in the directory
        /spool/dbox
    cdfsga:/spool/dbox% cd test2
    cdfsga:/spool/dbox/test2% addpkg -h JDBManager
    [.. lots of stuff..]
    cdfsga:/spool/dbox/test2% addpkg -h DBUtils
    [..stuff..]
    cdfsga:/spool/dbox/test2% addpkg -h CalibDBTables
    [..stuff..]
    
    cdfsga:/spool/dbox/test2% ls -la
    total 40
    drwxr-xr-x   12 dbox     cdf         4096 Jun 14 11:57 .
    drwxr-xr-x   22 dbox     cdf         4096 Jun 14 11:55 ..
    -rw-r--r--    1 dbox     cdf           12 Jun 14 11:55 .base_release
    drwxr-xr-x   13 dbox     cdf         4096 Jun 14 11:57 DBUtils
    -rwxr-xr-x    1 dbox     cdf          154 Jun 14 11:55 GNUmakefile
    drwxr-xr-x    7 dbox     cdf           94 Jun 14 11:56 JDBManager
    drwxr-xr-x    7 dbox     cdf           94 Jun 14 11:56 CalibDBTables
    drwxr-xr-x    2 dbox     cdf            9 Jun 14 11:55 bin
    drwxr-xr-x    2 dbox     cdf            9 Jun 14 11:55 doc
    drwxr-xr-x    2 dbox     cdf           50 Jun 14 11:57 include
    drwxr-xr-x    2 dbox     cdf            9 Jun 14 11:55 lib
    drwxr-xr-x    2 dbox     cdf            9 Jun 14 11:55 man
    drwxr-xr-x    2 dbox     cdf            9 Jun 14 11:55 results
    drwxr-xr-x    2 dbox     cdf            9 Jun 14 11:55 tmp
    drwxr-xr-x    2 dbox     cdf            9 Jun 14 11:55 ups
    

  2. Compile JDBManager library and DBUtils jExample programs
     
    cdfsga:/spool/dbox/test2% setup jfc
    cdfsga:/spool/dbox/test2% setup perl 
    cdfsga:/spool/dbox/test2% gmake codegen
    [..stuff..]
    cdfsga:/spool/dbox/test2% gmake -C JDBManager lib
    <**Installing**> /spool/dbox/test2/tmp/IRIX6-KCC_3_3/JDBManager/
    [..]
    
    cdfsga:/spool/dbox/test2% gmake -C DBUtils/jExamples tbin
    <**compiling**>  TESTDicts.java
    <**compiling application**>  jDBManager.java
    <**compiling application**>  jFillDB.java
    [..]
    
    

  3. Set the CLASSPATH by sourcing the setup.csh script
    cdfsga:/spool/dbox/test2% ls DBUtils/jExamples/
    BabyRunConfig    GNUmakefile      jDBManager.java  jReadDB.java
    CVS              TESTDicts.java   jFillDB.java     setup.csh
    cdfsga:/spool/dbox/test2%  source source DBUtils/jExamples/setup.csh 
    
    
    cdfsga:/spool/dbox/test2% ls bin/IRIX6-KCC_3_3/
    BabyRunConfig$1.class  implementations        jReadDB.class
    BabyRunConfig.class    jDBManager.class       tablestuff
    controls               jFillDB.class
    
    

  4. Now, run the jReadDB Example. We are reading out the calibration run 1 version 0 constants from the CMPCHEL table
    cdfsga:/spool/dbox/test2% java jReadDB
    Usage: java jDBManager    [jdbc_URL] [jdbc_driver]
    
    cdfsga:/spool/dbox/test2% java jReadDB 1 0 oracle
    file props/TableAlias.properties not found
    file TableAlias.properties not found
    couldnt find value for attribute:PROCESS_NAME, using default 
    couldnt find value for attribute:LAST_RUN, using default 
    couldnt find value for attribute:JOB_SET, using default 
    executing SELECT CMPCHEL.CHANNEL, CMPCHEL.TIMEZERO, CMPCHEL.SLOPE FROM CMPCHEL, CALIBRUNLISTS WHERE CALIBRUNLISTS.CALIB_TABLE = ?  AND CALIBRUNLISTS.CALIB_RUN= ?  AND CALIBRUNLISTS.CALIB_VERSION= ?  AND CMPCHEL.CID = CALIBRUNLISTS.CID with comp=CMPCHEL dataRun=1 version=0
    10 rows selected.
    ----------------------------------
    | channel  | timeZero |  slope   |
    ----------------------------------
    |    1     |0.86369348|0.84488338|
    |    2     |0.70960882|0.48711889|
    |    3     |0.84288901|0.41830134|
    |    4     |0.65593191|0.06396406|
    |    5     |0.00240245|0.03100252|
    |    6     |0.68755912|0.54491370|
    |    7     |0.28994129|0.40353530|
    |    8     |0.82244660|0.94482910|
    |    9     |0.44146452|0.67461115|
    |    10    |0.12013956|0.63431453|
    
    cdfsga:/spool/dbox/test2%  
    
    Dennis Box
    Last modified: Fri May 19 14:36:02 CDT 2000