This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JDBC and the fly likes Savepoints and transactions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Savepoints and transactions" Watch "Savepoints and transactions" New topic
Author

Savepoints and transactions

Tripp Bishop
Greenhorn

Joined: Aug 23, 2002
Posts: 21
Howdy all,
Here's my question. Given the following code:
Connection conn = null;
SavePoint savepoint = null;

try {
conn = ConnectionPool.getConnection();
dao mydao = new mydao();
mydao.task(conn);
savepoint = conn.setSavepoint("Beginning");
conn.commit();
mydao.anotherTask(conn);
conn.commit();
mydao.finalTask(conn);
conn.commit();
} catch(Exception e) {
conn.rollback(savepoint); // try/catch removed for clarity
} finally {
conn.close(); // try/catch removed for clarity
}
If I were to rollback to this save point (which is actually back to before the first command) and then closed the connection, would the transaction be terminated or would it be dangling on the database server, waiting for a commit() or rollback() to take place?
Thanks,
Tripp
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Savepoints and transactions