Hi,
I am not getting the sequence right the sequence of operations for
a database open in a servlet environment. It would be great if any one can
lead me in the right direction.
I am using OJB 0.9.7 in a servlet only environment with no EJBs in WAS.
Data connection is through a Datasource and WAS connection pooling is used
ODMG APIs are used.
The sequence of operations is as follows
1. The following lines are done once and stored in static variables.
odmg = OJB.getInstance();
/*
* Create a new Database for the broker instance
*/
database = odmg.newDatabase();
2. The database open is done once for very request.
database.open()
The problem is that when the user makes a new request. I am using the same
static instance of database on which a newDatabase has been done and put
into the static variable. This throws a Database already open error even
though a Database.close have been called in the earlier invocation.
3. To avoid this I cast the Database instance to a DatabaseImpl instance
and checked the state using isOpen method and then called the
datbase.open. But then when I was using the Transcation. On getting the
new transaction odmg.newTransaction(). I get an error that Transaction begun on a null
database and on
transaction.begin gives a null pointer exception.
4. All these problems were avoided if I did a odmg.newDatabase(); for every request.
But this was increasing the persistence broker count.
with the message in the log file Already created persistence broker
instances:number, with the number increasing with each call to the odmg.newDatabase();
I am not sure what to try next. Can any one tell me the right sequence of
calls. I tried the Beer4all code and the servlet example code in the test
src. Both didn't help me much.
Thanks in advance for the help
Jose