• Post Reply Bookmark Topic Watch Topic
  • New Topic

query on setAutoCommit()

 
nelson christos
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a function creates the connection setAutoCommit(false) and does some data updates
and in the finally block it closes the connection.

my question is whether closing the connection will commit any pending transactions if commit() is not called

thanks in advance
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on what type of connection you were using. If you are using Transactional (XA) connection then closing the connection will not commit automatically however if you are using non-transaction connections then it does commit before closing the connection.
 
nelson christos
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
anyway where can i get to know about different types of connection
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally you can obtain connection in two ways using DriverManager/DataSource for non-transactional connections and XADataSource for transactional connections. You need to consult your JDBC documentation to find out the implementation class for XADataSource interface, how to set data source properties and get connection.

Look at JDK java.sql and javax.sql packages in addition to the JDBC driver you are using.
[ November 06, 2006: Message edited by: Purushothaman Thambu ]
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!