| Author |
CMP and data retrieval
|
Sri Rangan
Ranch Hand
Joined: Dec 08, 2001
Posts: 160
|
|
We use CMP in our application, using VAJ . All the client requests are directed to the Entity Bean via Session Bean. I understand to retrieve data from database, it is not necessary to go thru the Entity Bean which will affect the performance. Is there a way to access the database directly from session bean for retrival of data. Since I do not directly handle the data access in CMP, how it could be done? Can I create my own connection pooling to access the data direclty from Session bean apart from container connection pooling for Entity Beans Thanks Sri
|
 |
Kiran Kumar
Ranch Hand
Joined: May 18, 2001
Posts: 107
|
|
hi u can create a datasource in the application server and lookup the datasource created and make use of the datasource for getting the database connections. this way u don't have to worry too much about DB connection since the server itself takes care of the pooling. within the session bean method u can lookup the datasource and get the connection and execute queries on the DB. hope this helps.
|
Thanks<br /> <br />Kiran <br /> <br />SCEA, SCJP 1.4,<br /> <br />"First they ignore u, then they laugh at u, then they fight u, <br />then u will win<br /> <br />Mahatma Gandhi"
|
 |
Guoqiao Sun
Ranch Hand
Joined: Jul 18, 2001
Posts: 317
|
|
Hi, Sri Rangan: You can do it in your session bean as well as in your entity bean in order to improve performance. I also do it in my project, in which if I find data from lot of record, I will write my own finder method. First you should get the DataSource using JNDI, then retrive a Conntection object from the DataSource. After that, you just do it in a normal SQL programming way. Hope it helps, Guoqiao
Originally posted by Sri Rangan: We use CMP in our application, using VAJ . All the client requests are directed to the Entity Bean via Session Bean. I understand to retrieve data from database, it is not necessary to go thru the Entity Bean which will affect the performance. Is there a way to access the database directly from session bean for retrival of data. Since I do not directly handle the data access in CMP, how it could be done? Can I create my own connection pooling to access the data direclty from Session bean apart from container connection pooling for Entity Beans Thanks Sri
|
Guoqiao Sun<br />SCJP2 SCWCD2<br />Creator of <a href="http://www.jiris.com/" target="_blank" rel="nofollow">www.jiris.com</a>, Java resource, mock exam, forum
|
 |
 |
|
|
subject: CMP and data retrieval
|
|
|