aspose file tools*
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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Savepoints and transactions" Watch "Savepoints and transactions" New topic

Savepoints and transactions

Tripp Bishop

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();
savepoint = conn.setSavepoint("Beginning");
} 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?
I agree. Here's the link:
subject: Savepoints and transactions
Similar Threads
how to Handle Transaction Management in Servlets?
Savepoint/Rollback Through EJB
ThreadLocal and DB connection...
java.sql.SQLException[ODBC Driver Manager]Data source name not found and no default driver specified
close sql connection in finally block