• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
sunil mirani
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sunil mirani
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic