The Artima Developer Community
Sponsored Link

Java Answers Forum
connection.setAutoCommit(false) commits after each update?

1 reply on 1 page. Most recent reply: Feb 24, 2004 2:26 AM by Viswanatha Basavalingappa

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
SK

Posts: 1
Nickname: dearkoala
Registered: Feb, 2004

connection.setAutoCommit(false) commits after each update? Posted: Feb 23, 2004 9:35 PM
Reply to this message Reply
Advertisement
I have codes in jsp where I grab a database connection, set auto commit to <b>false</b>, did an update via executeUpdate and rollback. What happens is... when I display the auto commit status using getAutoCommit(), it shows true, and the data are updated to the database.
<br><br>
I'm using JDK 1.3.1 and Oracle DB 9.0.1.3.
<br><br>
Below is an extract of my code.
<br>


try {<br>
Context ic = new InitialContext();<br>
DataSource ds = (DataSource)ic.lookup((String) application.getAttribute("dataSource"));<br>
con = ds.getConnection();<br>

con.setAutoCommit(false); <br>
out.println(con.getAutoCommit()); // displayed true during execution.<br>

stmt = con.createStatement();<br>
stmt.executeUpdate(...);<br>
con.rollbac k();<br>
con.close();<br>
}<br>
catch {<br>
...<br>
}<br>
finally {<br>
...<br>
}<br><br>

TIA.


Viswanatha Basavalingappa

Posts: 84
Nickname: viswagb
Registered: Nov, 2003

Re: connection.setAutoCommit(false) commits after each update? Posted: Feb 24, 2004 2:26 AM
Reply to this message Reply
Hi,
Yes this kind arises some time....solution is ..
To make autoCommit mode off /on You need to use the property 'SelectMethod' for the driver in the URL and set it to 'cursor'

So your driver url should be like :

"jdbc:oracle:thin:@dbmachine:1433;SelectMethod=cursor"

Try this and let me know is it works or not..!!!

Viswa
-------

Flat View: This topic has 1 reply on 1 page
Topic: How To Continue With The Code for Sales Program Previous Topic   Next Topic Topic: Object oriented programming

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use