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, 11 Mar 2005 19:13:23 GMT
mkalen      2005/03/11 11:13:23

  Modified:    src/java/org/apache/ojb/broker/platforms
                        PlatformOracle9iImpl.java
  Log:
  Merge with OJB_1_0_RELEASE branch: 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
  1.15      +31 -26    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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- PlatformOracle9iImpl.java	15 Aug 2004 22:39:11 -0000	1.14
  +++ PlatformOracle9iImpl.java	11 Mar 2005 19:13:23 -0000	1.15
  @@ -37,16 +37,16 @@
    * an implementation that uses Oracle specific optimizations and LOB-handling.
    *
    * Optimization: Oracle Batching (not standard JDBC batching)
  - * see http://technet.oracle.com/products/oracle9i/daily/jun07.html
  + * see <a href="http://technet.oracle.com/products/oracle9i/daily/jun07.html">OTN</a>.
    *
    * Optimization: Oracle Prefetching
  - * see http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/advanced/RowPrefetchSample/Readme.html
  + * see <a href="http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/advanced/RowPrefetchSample/Readme.html">OTN</a>
    *
    * Optimization: Oracle Statement Caching
  - * see http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/jdbc30/StmtCacheSample/Readme.html
  + * see <a href="http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/jdbc30/StmtCacheSample/Readme.html">OTN</a>
    *
    * TODO: Optimization: use ROWNUM to minimize the effects of not having server side cursors
  - * see http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:127412348064
  + * see <a href="http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:127412348064">Ask
TOM</A>.
    *
    * @author <a href="mailto:mattbaird@yahoo.com">Matthew Baird</a>
    * @author <a href="mailto:erik@cj.com">Erik Forkalsrud</a>
  @@ -60,8 +60,22 @@
   {
       private Logger logger = LoggerFactory.getLogger(PlatformOracle9iImpl.class);
   
  -    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."
  @@ -81,12 +95,16 @@
       protected static final JdbcType BASE_BLOB = JdbcTypesHelper.getJdbcTypeByName("blob");
   
       /**
  -     * Enables Oracle statement caching if supported by the JDBC-driver.
  +     * Enables Oracle statement caching and row prefetching if supported by the JDBC-driver.
        * See
        * {@link "http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/jdbc30/StmtCacheSample/Readme.html"}
        * @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
       {
  @@ -110,26 +128,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)
  @@ -137,11 +142,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