java.sql Code Samples
- How do I get data types supported by database?
- How do I set the query timeout limit?
- How do I get system functions supported by database?
- How do I know if database support batch update?
- How do I know if database support transaction?
- How do I know if database support updatable result sets?
- How do I get database product information?
- How to automatically close resources in JDBC?
- How do I know if database support scrollable result sets?
- How do I limit MySQL query result?
- How do I set the maximum rows to read in a query?
- How do I call a stored procedure that return a result set?
- How do I get the maximum number of concurrent connections?
- How do I set the fetch size of a statement?
How do I commit or rollback transaction in JDBC?
Executing a database manipulation command such as insert, update or delete can sometime throws exception due to invalid data. To protect the integrity of our application data we must make sure when we a transaction was failed we must rollback all the executed command so that it affect the state of our data.
In this example we are using MySQL database. To enable transaction capability in MySQL make sure that you are using InnoDB storage engine to create the your tables.