View RSS Feed

Recent Blogs Posts

  1. PreparedStatement Performance

    by , 04-27-2012 at 08:11 PM
    It takes time for a database to parse an SQL string, and create a query plan for it. A query plan is an analysis of how the database can execute the query in the most efficient way.
    If you submit a new, full SQL statement for every query or update to the database, the database has to parse the SQL and for queries create a query plan. By reusing an existing PreparedStatement you can reuse both the SQL parsing and query plan for subsequent queries. This speeds up query execution, by decreasing ...
  2. Supplying Values for PreparedStatement Parameters

    by , 04-27-2012 at 08:08 PM
    You must supply values in place of the question mark placeholders (if there are any) before you can execute a PreparedStatement object. Do this by calling one of the setter methods defined in the PreparedStatement class. The following statements supply the two question mark placeholders in the PreparedStatement named updateSales:

    Java Code:
    updateSales.setInt(1, e.getValue().intValue());
    updateSales.setString(2, e.getKey());
    The first argument for each of ...
  3. Prepared statement pooling (JDBC 3.0)

    by , 11-28-2011 at 07:35 PM (My Java Tips)
    JDBC 3.0 provides improved connection pooling. This post is all about that.



    It is also possible to pool prepared statements. A prepared statement allows us to keep frequently used SQL statement in a pre-compile form, thus improving performance if that statement is executed multiple times. But there is a dark side of this. Creating a PreparedStatement object introduces a certain amount of overhead. There are some developers sometimes change their object models to increase the ...
    Categories
    JDBC
  4. Wrapping JDBC Objects

    by , 05-25-2011 at 10:55 AM (My Java Tips)
    In Glassfish connection pool has a property called "Wrap JDBC Objects" which can have value true or false. You may define it in domain.xml file.

    This property is defined as: "When set to true, application will get wrapped jdbc objects for Statement, PreparedStatement, CallableStatement, ResultSet, DatabaseMetaData".

    If you follow JDBC specifications, you will be see that obtaining connection using DataSource.getConnection() or other objects like ...