loading HSQL in-memory from different JVM processes

From: Albretch (lbrtchx_at_hotmail.com)
Date: 02/06/05


Date: Sun, 6 Feb 2005 13:02:57 -0500 (EST)


 I need to load Hypersonic SQL working in-memory
from different OS processes and make sure each of

these independent OS/JVM processes have their own
copy of the HSQL in their own memory space.

 While testing, I noticed some things didn't look
right (themselves or to my eyes)

 I took the time to reduce the problem to a few files.

 1._ One file runs a batch, that (primary.bat)

 2._ invokes a number of batch files (worker00.bat,
worker02.bat, worker04.bat), each of which

 3._ starts a JVM process to run a java program
(inmemhs00.java)

 Now, the thing is that all instances of HSQL appear
to be the same one loaded from the same class loader
(?!?) even though they are started from different
processes an you can even see that they are loaded
from another procees before the previous one ended.

 To me this should not be happening. Can anyone spot
the error or tell me what I am conceptually missing
here?

 I did my test on windows:

java -version
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

, but I think this should not be happening on any OS
anyway.

// - - - primary.bat
javac *.java

rem set CLASSPATH=%WHEREVER_IT_IS%\hsqldb.jar;.;

start worker00

start worker02

start worker04

// - - - worker00.bat
java -verbose inmemhs00 > worker00.txt 2>&1

// - - - worker02.bat
java -verbose inmemhs00 > worker02.txt 2>&1

// - - - worker04.bat
java -verbose inmemhs00 > worker04.txt 2>&1

// - - - inmemhs00.java
import java.io.*;
import java.util.*;
import java.sql.*;

class hs00{

 public boolean getInMemCx(String aHSQLDBProps){
  boolean IsCx = false;
// __
  Class K = this.getClass();

  int iKLdrs = 0;
  ClassLoader KLdr = K.getClassLoader();
  while(KLdr != null){
   System.err.println("// __ " + iKLdrs + " : |" + KLdr.toString() + "|");
   KLdr = KLdr.getParent();
   ++iKLdrs;
  }
  System.err.println("// __ class name: |" + K.getClass().getName() + "|");
  System.err.println("// __ this: |" + this + "|");
  Properties Prop;
// __
  try{
   Prop = new Properties();
   Prop.load(new FileInputStream(aHSQLDBProps));
   Prop.list(System.err);
// __
   System.err.println("// __");
   String aDrvr = Prop.getProperty("driver");
   String aDBURL = Prop.getProperty("url");
   String aDB = Prop.getProperty("database");
   String aUser = Prop.getProperty("user");
   String aPW = Prop.getProperty("password");
   String aTest = Prop.getProperty("test");
   String aLog = Prop.getProperty("log");
   System.err.println("// __");
// __

// __
   Class.forName(aDrvr).newInstance();
   Connection DBCx = DriverManager.getConnection(aDBURL + aDB, aUser, aPW);
// __
   System.err.println("// __ DBCx: |" + DBCx + "|");
// __
   String aCatalog = DBCx.getCatalog();
   int iSol = DBCx.getTransactionIsolation();
   boolean IsRO = DBCx.isReadOnly();
   boolean IsAutoCommit = DBCx.getAutoCommit();
// __
   System.err.println("// __ aCatalog: |" + aCatalog + "|");
   System.err.println("// __ iSol: |" + iSol + "|");
   System.err.println("// __ IsRO: |" + IsRO + "|");
   System.err.println("// __ IsAutoCommit: |" + IsAutoCommit + "|");
// __
   DatabaseMetaData DBMD = DBCx.getMetaData();
// __
   System.err.println("// __ DBMD: |" + DBMD + "|");
// __
   String aProdName = DBMD.getDatabaseProductName();
   String aVersion = DBMD.getDatabaseProductVersion();
   String aURL = DBMD.getURL();
   String aUserName = DBMD.getUserName();
// __
   System.err.println("// __ aProdName: |" + aProdName + "|");
   System.err.println("// __ aVersion: |" + aVersion + "|");
   System.err.println("// __ aURL: |" + aURL + "|");
   System.err.println("// __ aUserName: |" + aUserName + "|");
// __
   DBCx.close();
// __
   IsCx = true;
  }catch(Exception X){ X.printStackTrace(); }
// __
  return(IsCx);
 }
}

public class inmemhs00{
 private static final String aHSQLDBProps = "./hsqldbmem.propeties";
 public static void main(String[] aArgs){
  long lTm00 = System.currentTimeMillis();
  System.out.println("// __ Starting Time Millis: |" + lTm00 + "|");
  hs00 hs = new hs00();
  if(hs.getInMemCx(aHSQLDBProps)){
   System.err.println("// __ Connection OK!");
   System.err.println("// __ hs: |" + hs + "|");
  }
  long lTm02 = System.currentTimeMillis();
  System.out.println("// __ Starting Time Millis: |" + lTm02 + "|");
  System.out.println("// __ Time Diff: |" + (lTm02 - lTm00) + "|");
 }
}



Relevant Pages

  • loading HSQL in-memory from different JVM processes
    ... 3._ starts a JVM process to run a java program ... the thing is that all instances of HSQL appear ... public boolean getInMemCx{ ... String aProdName = DBMD.getDatabaseProductName; ...
    (comp.lang.java.programmer)
  • Re: stupid question...waiting for a stupid answer
    ... should use String instead of boolean to pass by reference? ... Java doesn't do pass by reference: ...
    (comp.lang.java.programmer)
  • Connecting to Sharepoint Problem
    ... String bstrCurrentFolderUrl, Boolean& pbCanCustomizePages, Boolean& ... pVerGhostedSetupPath, UInt32& pdwPartCount, Object& pvarMetaData, ... pbstrRedirectUrl, Boolean& pbObjectIsList, Guid& pgListId, UInt32& ...
    (microsoft.public.biztalk.general)
  • Re: Connecting to Sharepoint Problem
    ... String bstrCurrentFolderUrl, Boolean& pbCanCustomizePages, Boolean& ... pVerGhostedSetupPath, UInt32& pdwPartCount, Object& pvarMetaData, ... pbstrRedirectUrl, Boolean& pbObjectIsList, Guid& pgListId, UInt32& ...
    (microsoft.public.biztalk.general)
  • RE: installation WSS 3.0
    ... <exception, Boolean breakConnection) ... <owningObject, SqlConnectionString connectionOptions, String newPassword, ... <newDatabaseId, String strDatabaseServer, String strDatabaseName, String ... <databaseServer, String databaseName, String databaseUsername, String ...
    (microsoft.public.windows.server.sbs)