Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

transactions/statements per connection

 
Ishita Gupta
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody,
I have heard that JDBC allows only one active transaction or statement object per connection.
Why is there such a limitation.
I am sure this limitation needs to be understood for a thorough use of the JDBC, as such.
Thanx in advance.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
like_java,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!
 
Vamshi Krishna
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am working upon Java these days. I could not found any restruction as you said. I think you can have two or more statements objects for a single connection object.
If you think we can not or found a reason that we can not do that, please let me know about it. I am looking forward for the reason if we can not create muntiple statement objects on a single connection object.
Hope you get back to me. Your help is appreciated
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have multiple Statement objects per Connection. No problem there.
However, when it comes to transactions, things get more complicated and there are probably many database drivers that cannot cope with two transactions over a single connection.
I remember reading a thread here at JavaRanch about this issue of of connection sharing with multiple transactions.
[ June 17, 2003: Message edited by: Lasse Koskela ]
 
Jamal Anvar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ishita,

You can create any number of statements using the same connections at a time. Each statement can have a resultset each at a time. There is no limit as such except the database level limits like max number of open cursors etc.
But I think you cant run two SQL statements using two statements at a time concurrently (possibly using different threads as in servlets). I think this is restricted by database and not driver. If you fire two SQLs using different statements out of the same connection, the second one will wait for the first one to complete the execution.
I have based Oracle database in my explanation.
Does any one have any other explanation for this?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic