db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mka...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/platforms PlatformOracle9iImpl.java
Date Fri, 25 Feb 2005 19:08:15 GMT
mkalen      2005/02/25 11:08:15

  Modified:    src/java/org/apache/ojb/broker/platforms Tag:
                        OJB_1_0_RELEASE PlatformOracle9iImpl.java
  Log:
  Lower sizes for Oracle-specific row pre-fetch and statement cache. This optimizes memory
consumption and avoids OutOfMemoryException when using Oracle9i platform (heavy caching in
JDBC driver see to make JVM GC unable to reclaim references under low memory conditions).
Also make pre-fetch enable only once per connection instead of once per statement.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.13.2.1  +28 -25    db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformOracle9iImpl.java
  
  Index: PlatformOracle9iImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformOracle9iImpl.java,v
  retrieving revision 1.13
  retrieving revision 1.13.2.1
  diff -u -r1.13 -r1.13.2.1
  --- PlatformOracle9iImpl.java	22 May 2004 09:55:33 -0000	1.13
  +++ PlatformOracle9iImpl.java	25 Feb 2005 19:08:15 -0000	1.13.2.1
  @@ -49,7 +49,7 @@
    *
    * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
    * @author <a href="mailto:erik@cj.com">Erik Forkalsrud</a>
  - * @author <a href="mailto:martin.kalen@curalia.se">Martin Kal&eacute;n</a>
  + * @author <a href="mailto:mkalen@apache.org">Martin Kal&eacute;n</a>
    * @version CVS $Id$
    * @see Platform
    * @see PlatformDefaultImpl
  @@ -57,8 +57,22 @@
    */
   public class PlatformOracle9iImpl extends PlatformOracleImpl
   {
  -    protected static final int STATEMENT_CACHE_SIZE = 100;
  -    protected static final int ROW_PREFETCH_SIZE = 100;
  +    /**
  +     * Number of cached statements per connection,
  +     * when using implicit caching with OracleConnections.
  +     * Set in {@link #initializeJdbcConnection}.
  +     * @see <a href="http://www.apache.org/~mkalen/ojb/broker-tests.html">Profiling
page</a>
  +     * for a discussion re sizing
  +     */
  +    protected static final int STATEMENT_CACHE_SIZE = 10;
  +    /**
  +     * Number of rows pre-fetched by the JDBC-driver for each executed query,
  +     * when using Oracle row pre-fetching with OracleConnections.
  +     * Set in {@link #initializeJdbcConnection}.
  +     * @see <a href="http://www.apache.org/~mkalen/ojb/broker-tests.html">Profiling
page</a>
  +     * for a discussion re sizing
  +     */
  +    protected static final int ROW_PREFETCH_SIZE = 10;
   
       // From Oracle9i JDBC Developer's Guide and Reference:
       // "Batch values between 5 and 30 tend to be the most effective."
  @@ -78,12 +92,14 @@
       protected static final JdbcType BASE_BLOB = JdbcTypesHelper.getJdbcTypeByName("blob");
   
       /**
  -     * Enables Oracle statement caching if supported by the JDBC-driver.
  -     * See
  -     * {@link "http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/jdbc30/StmtCacheSample/Readme.html"}
  +     * Enables Oracle statement caching and row prefetching if supported by the JDBC-driver.
        * @param jcd the OJB <code>JdbcConnectionDescriptor</code> (metadata)
for the connection to be initialized
        * @param conn the <code>Connection</code>-object (physical) to be initialized
        * @see PlatformDefaultImpl#initializeJdbcConnection
  +     * @see <a href="http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/jdbc30/StmtCacheSample/Readme.html">
  +     * Oracle TechNet Statement Caching Sample</a>
  +     * @see <a href="http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/advanced/RowPrefetchSample/Readme.html">
  +     * Oracle TechNet Row Pre-fetch Sample<a>
        */
       public void initializeJdbcConnection(JdbcConnectionDescriptor jcd, Connection conn)
throws PlatformException
       {
  @@ -107,26 +123,13 @@
               }
               catch (Exception e)
               {
  -                throw new PlatformException(e.getLocalizedMessage(), e);
  +                throw new PlatformException(e);
               }
           }
  -    }
   
  -    /**
  -     * Enables Oracle row prefetching if supported.
  -     * See http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/advanced/RowPrefetchSample/Readme.html.
  -     * This is RDBMS server-to-client prefetching and thus one layer below
  -     * the OJB-internal prefetching-to-cache introduced in version 1.0rc5.
  -     * @param stmt the statement just created
  -     * @throws PlatformException upon JDBC failure
  -     */
  -    public void afterStatementCreate(java.sql.Statement stmt) throws PlatformException
  -    {
  -        super.afterStatementCreate(stmt);
  -
  -        // Check for OracleStatement-specific row prefetching support
  +        // Check for OracleConnection-specific row pre-fetching support
           final Method methodSetRowPrefetch;
  -        methodSetRowPrefetch = ClassHelper.getMethod(stmt, "setRowPrefetch", PARAM_TYPE_INTEGER);
  +        methodSetRowPrefetch = ClassHelper.getMethod(conn, "setDefaultRowPrefetch", PARAM_TYPE_INTEGER);
   
           final boolean rowPrefetchingSupported = methodSetRowPrefetch != null;
           if (rowPrefetchingSupported)
  @@ -134,11 +137,11 @@
               try
               {
                   // Set number of prefetched rows
  -                methodSetRowPrefetch.invoke(stmt, PARAM_ROW_PREFETCH_SIZE);
  +                methodSetRowPrefetch.invoke(conn, PARAM_ROW_PREFETCH_SIZE);
               }
               catch (Exception e)
               {
  -                throw new PlatformException(e.getLocalizedMessage(), e);
  +                throw new PlatformException(e);
               }
           }
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message