aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes instance management .... facing serious problem ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "instance management .... facing serious problem ..." Watch "instance management .... facing serious problem ..." New topic
Author

instance management .... facing serious problem ...

sunil mirani
Ranch Hand

Joined: Jan 24, 2001
Posts: 36
Hi everyone ,
i have a problem with entity bean .. i am using BMP ...
when a client invokes the entity bean the instance is created ..
it establishes connection with database (i have utility method that establishes connection .. getConnection()).. for the method calls .. but these connection are not getting closed (when i write conn.close().. it does not throw an error too ..!!)i am closing the connection in the finally block of each method....
once the program has made around 150 calls .. oracle throws an error "excceding 150 process " (so i asumed that connection is not being closed)
how do i do connection pooling .. i thought this was handled by the container ..i am using J2ee refence server ..
another doubt ..
say i have 150 records(rows) in the table ... diffrent clients need to access these rows ... now when one client invokes a findByPrimarykey(DataPK dpk) on the entity bean ..
and if another client needs to access the same data ... so can i have the client to access the same instance created by the first time rather than the client creating a new instance ..
because in the kind of application i am working on many clients need to access the same data ...
and this data gets refreshed / updated by another client altogether ..
some thing like the Stock Quotes .. where many clients access the stock quote .. but at a time stamp the data is getting updated in the database ..
can any one help what approch i should take towards this ...
Thanks,
Sunil
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

The Primary Key of an EJB is NOT a database key! It is, in fact, an identifier that is used to uniquely distinguish one EJB from another (it just often happens to CONTAIN one or more database key field values). So if if you have 2 clients getting a bean by primary key, or if two client requests are getting results in which the same primary key are returned, you are guaranteed by the architecture that they're both referencing the same EJB.
For that EJB, the interface's transaction characteristics assure that no 2 clients can simultaneously access that bean. So most of your problem has been anticipated and solved already.
Your connection overload I don't know about. However, if you do your own jdbc, there's no way for an outside agency (the container) to know what you're doing. The best you can do is have the container supply a pooling jdbc interface and work with that.


Customer surveys are for companies who didn't pay proper attention to begin with.
sunil mirani
Ranch Hand

Joined: Jan 24, 2001
Posts: 36
Hello Tim ,
Thanks man .. that helped .. i'll try the connection pooling today .. but i have a doubt but its back to fundamentals ..
in a class say we have a constructor which has a static variable .. now i use the ++ operator to keep track ofhow many instances of the class are being created .. right ..
now i tried this same thing with ejb to see how many instances are being created of the bean .. and the count increases even if i am instanciating the bean with the same PK ...so how do i know if the instance is same or diffrent ..
Thanks,
Sunil
ps .. thanks for your reply
Mahesh Kulkarni
Ranch Hand

Joined: Jul 05, 2001
Posts: 62
Hi Sunil,
This is the problem of oracle.You have to set no of processes in
init.ora file of your oracle installation.
We faced the same problem,but after setting the processes parameter in given file everything is working fine.
Thanx,
Mahesh
sunil mirani
Ranch Hand

Joined: Jan 24, 2001
Posts: 36
Hello Mahesh ,
Thanks for the reply .. its not an oracle error .. i checked the code and i realised the connection was not closed properly .. i had made a silly error .
Thanks,
Sunil
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: instance management .... facing serious problem ...