Services
|
Products
|
News Events
|
|
Best practices to improve performance in JDBC
|
Best practices to improve performance in JDBC
- Get database connection from connection pool rather than getting it directly
- Use batch transactions.
- Choose right isolation level as per your requirement. TRANSACTION_READ_UNCOMMITED gives best performance for concurrent transaction based applications. TRANSACTION_NONE gives best performance for non-concurrent transaction based applications.
- Your database server may not support all isolation levels, be aware of your database server features.
- Use PreparedStatement when you execute the same statement more than once.
- Use CallableStatement when you want result from multiple and complex statements for a single request.
- Use batch update facility available in Statements.
- Use batch retrieval facility available in Statements or ResultSet.
- Set up proper direction for processing rows.
- Use proper getXXX() methods.
- Close ResultSet, Statement and Connection whenever you finish your work with them.
- Write precise SQL queries.
- Cache read-only and read-mostly tables data.
|
|