loading HSQL in-memory from different JVM processes

A

Albretch

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) + "|");
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top