Wednesday, September 4, 2013

How to have a Better Java/JDBC Performance

1. By default the JDBC driver commits all INSERTs and UPDATEs as soon as you execute the statement.  This is known as autoCommit mode in JDBC.  You can get better performance by turning autoCommit off and using explicit commit statements.  Use setAutoCommit entrypoint of the Connection class to turn off autoCommit:

For Example:

connection.setAutoCommit(false);

2. Use Batch Updates in the JDBC when possible.  Batching INSERT and UPDATE calls can achieve even more speed than turning off autoCommit.

3. Use exact Java classes through import at the beginning of the code.  e.g., JDBC driver / JDK using sql and math combinations, add the following lines to your IMPORT statements:

     import java.sql.*;
     import java.math.*;

4.  Performance optimizations include:

* Client-to-server round trip reductions for binds, defines, and describes
* Batched statement execution
* Row pre-fetching
* Array interface
* Client side statement caching

Keywords: JDBC, JDK, Eclipse, IDE, Maven, JDBC OCI, JDBC THIN, OCI, THIN

No comments:

Post a Comment