• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CMP and data retrieval

 
Sri Rangan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Guoqiao Sun
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic