How do I disable auto commit mode in JDBC?
Category: java.sql, viewed: 619 time(s).
The code fragment below show you how we disable auto commit operation when executing a JDBC command.
package org.kodejava.example.sql; import java.sql.Connection; import java.sql.SQLException; public class CommitSettingExample { public static void main(String[] args) { Connection connection = null; try { // // DO: Get a connection to database, we need to obtain the // database connection prior to executing any JDBC commands/ // // // Disable the auto-commit operation. By default every statement // executed against database in JDBC is in auto-commit mode. To // disable auto-commit set it to false // connection.setAutoCommit(false); // // DO: Execute some other database operation here // // // Finally we must call the commit method explicitly to finish // all database manipulation operation // connection.commit(); } catch (SQLException e) { e.printStackTrace(); } } } |
Can't find what you are looking for? Join our FORUMS and ask some questions!
Related Examples
- How do I make updates in Updatable ResultSet?
- How do I create a batch update in JDBC?
- How do I create a scrollable result sets?
- How do I move to absolute or relative row?
- How do I know the current position of cursor?
- How do I check if cursor is in the last row?
- How do I check if cursor is in the first row?
- How do I move cursor to the last record?
- How do I move cursor in scrollable result sets?
- How do I use DatabaseMetaData to get table column names?