Loading
JDBC Tuning

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  JDBC Tuning


Ans)

1) Turn off auto-commit for better performance, especially when you use callable statements
    or just querying database.
    conn.setAutoCommit(false);
 2) Use the PreparedStatement object for overall database efficiency.
     When you use a PreparedStatement object to execute a SQL statement, the statement is
     parsed and compiled by the database, and then placed in a statement cache.
 3) Use PreparedStatements for batching repetitive inserts or updates.
     With Oracle, you can choose standard JDBC batching using the addBatch() and executeBatch()
     methods, or you can choose Oracle's proprietary method, which is faster, by utilizing the
    OraclePreparedStatement's setExecuteBatch() method along with the standard executeUpdate()
    method.

  To use Oracle's proprietary batching mechanism, call setExecuteBatch() as follows:    
       PreparedStatement pstmt3D null;
          try {
              ((OraclePreparedStatement)pstmt).setExecuteBatch(30);
              pstmt.executeUpdate();
       }

4) Create Indexes on your Database Bases.
 5) Use DataBase Views instead of using tables for quering.
 6)Set the dataBase PageSize properly to appropriately value.
 7) The higher the level of transaction protection, the higher the performance penalty.
 Transaction levels in order of increasing level are:
 TRANSACTION_NONE,
 TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED, TRANSACTION_REPEATABLE_READ,
 TRANSACTION_SERIALIZABLE. Use Connection.setTransactionIsolation() to set the desired
 tansaction level.
8)  The default autocommit mode imposes a performance penalty by making every database
    command a separate transaction. Turn off autocommit (Connection.setAutoCommit(false)),
        and explicitly specify transactions.
    Use Connection.setReadOnly(true) to optimize read-only database interactions.



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

JDBC Tuning


JDBC Tuning

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free