Refresh Your Java - Before Java Interview
We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....
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.
This Portal is intended to put all Java/J2ee related topics at one single place for quick referance, not only Technical , but also the Project Management Related thing such as Development Process methodoogies build process, unit testing etc.,
This Portal has More than 500 Java Interview Questions (also could be Considered as Quick Notes) very neatly separated topic by topic with simple diagrams which makes you easily understandable. Importantly these are from our Realtime expericance.