The problem is the jsp page is not able to get the desired results that i.e. bean B is not able to query the data base successfully. The is so because the query , though the method is called afterwards, tries to query the table for the record before the insert statement in executed. When I check the database, the record is inserted into the table.I have arrived at this conclusion because , when the page is refreshed the query is executed . Probably this gives time for the inserted statement of bean A to the executed before the query statement of bean B is called.
I have also tried to call the method of bean B in bean A .
Kindly help me get over this problem as i need to know the product code immediately after the insert statement
Originally posted by josxavier:
[...] My jsp page executes a method in bean A which inserts the product name into the table. And my next line of code calls another method of bean B which queries the same table [...] though the method is called afterwards, tries to query the table for the record before the insert statement in executed. When I check the database, the record is inserted into the table.
If you used two different Connection objects, the database may not show you the result of your insert until you have actually committed the transaction.
Could this be the problem?
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements.