> Yes -- have a look at the Sun JDBC tutorial:http://java.sun.com/docs/books/tutorial/jdbc/basics/transactions.html
But it would require me to pass around the connection object and
keeping it alive, not to mention changing the function prototype.
Isn't there an other way of doing it? Thanks for your help.
Kai Schwebke - 09 May 2007 20:43 GMT
getsanjay.sharma@gmail.com schrieb:
>> Yes -- have a look at the Sun JDBC tutorial:http://java.sun.com/docs/books/tutorial/jdbc/basics/transactions.html
> But it would require me to pass around the connection object and
> keeping it alive, not to mention changing the function prototype.
> Isn't there an other way of doing it? Thanks for your help.
The database may be used by many different users (=connections)
in parallel. So a transaction has to be scoped somehow.
This scope is the connection.
Passing the connection around is one of the simplest ways to
achieve thread safety, which is needed in a servlet environment.
Kai
Wojtek - 09 May 2007 20:44 GMT
getsanjay.sharma@gmail.com wrote :
>> Yes -- have a look at the Sun JDBC
>> tutorial:http://java.sun.com/docs/books/tutorial/jdbc/basics/transactions.html
>
> But it would require me to pass around the connection object and
> keeping it alive, not to mention changing the function prototype.
> Isn't there an other way of doing it? Thanks for your help.
So you want to start a transaction, then go back to the user to get
more information, then continue with the transaction, etc?
This is a bad idea. Not only are you holding open a connection to the
database for an unknown but really large amount of time, but you do not
know if the user will get bored and not continue with the process.
Plus if you have many users, you will need many connections.
Change the way you do things. Get ALL the user input first, storing
intermediate stages in the session, then process all the information
into the various tables in one operation.

Signature
Wojtek :-)
getsanjay.sharma@gmail.com - 10 May 2007 02:56 GMT
Thanks a lot for all your input. Normally I shove all this work on to
the App server while developing Entity beans and move along with it.
Passing connection around seemed not such a good idea. Maybe I would
just configure the Datasource in the Tomcat Web server and look into
some docs to see if it leads to something.
Thank you.
Harry - 10 May 2007 03:05 GMT
Hi,
If you're using non-EJB, I think the only way to do transaction is
using connection object as stated above. What I would like to say is
setting Datasource does not change the statement, as this only
provides you with the connection pool, you still need the connection
object to control the transaction.
Regards,
Harry
On May 9, 6:56 pm, getsanjay.sha...@gmail.com wrote:
> Thanks a lot for all your input. Normally I shove all this work on to
> the App server while developing Entity beans and move along with it.
[quoted text clipped - 3 lines]
>
> Thank you.
getsanjay.sharma@gmail.com - 10 May 2007 19:35 GMT
Thanks Harry, would keep that in mind.