dcsimg
Weblogic pool connection Vs JDBC Connection
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Srikanth_S
Posted On:   Thursday, November 27, 2003 05:12 AM

Inserted data using ejbCreate() method of CMP Bean. In the very next line i am trying to read the data using a JDBC connection (note that this is direct JDBC Connection,not a weblogic pool connection). I am not able to read the data. Following is the pseudocode of what I am doing: Begin User Transaction; Call ejbCreate() method of CMP Bean (Insert record in database); Open JDBC connection(user name, password, driver, datasource); read record from database using JDBC connection (This read does not return the inserted data through ejbCreate()) End User Transaction; Pls help . -Thanks, Srikanth    More>>

Inserted data using ejbCreate() method of CMP Bean.
In the very next line i am trying to read the data using a JDBC connection (note that this is direct JDBC Connection,not a weblogic pool connection).
I am not able to read the data.

Following is the pseudocode of what I am doing:


Begin User Transaction;

Call ejbCreate() method of CMP Bean (Insert record in database);

Open JDBC connection(user name, password, driver, datasource);

read record from database using JDBC connection
(This read does not return the inserted data through ejbCreate())

End User Transaction;


Pls help .
-Thanks,
Srikanth

   <<Less

Re: Weblogic pool connection Vs JDBC Connection

Posted By:   Nick_Maiorano  
Posted On:   Saturday, November 29, 2003 09:32 AM

Srikanth,



I will tell you why you are having this problem but you must know that you have a bigger problem which is your design. You should never use JDBC inside a CMP entity bean. You are defeating the purpose of CMP which is abstract all JDBC code for you. If you want to use JDBC, then you should use BMP instead.



Anyways, the reason for your error is because you are using 2 different database connections to access your database: 1 for your entity bean and another for your JDBC connection. As such, your JDBC connection does not yet see the insert done by ejbCreate() because it has not yet committed the transaction. Besides, why are you going to the database with JDBC when your entity bean already has all the data in memory?



Regardless, you must re-design your bean. Don't do JDBC inside a CMP bean.

About | Sitemap | Contact