Search code examples
oracle-databasetomcatoracle11gprefetch

how to set default prefetch row size in tomcat for oracle connection


Hi I want to be able to set defaultRowPrefetch in tomcat server configuration.

If it is possible, i want to programmatic avoid setting default prefetch row.

Example: (OracleConnection(conn)).setRowPrefetch(20);

However, I want to set the default row prefetch variable in tomcat server.xml configuration.

<Resource
            name="myDataSource"
            type="javax.sql.DataSource"
            password="#######"
            driverClassName="oracle.jdbc.driver.OracleDriver"
    <!-- more information -->
    />

Solution

  • You can use attribute "connectionProperties" of Resource tag documented here https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html. The connection property to set is "defaultRowPrefetch".

    Your configuration will be:

    <Resource
            name="myDataSource"
            type="javax.sql.DataSource"
            password="#######"
            driverClassName="oracle.jdbc.driver.OracleDriver"
            connectionProperties="defaultRowPrefetch=20"
    <!-- more information -->
    />
    

    To check configuration you can invoke: (OracleConnection(conn)).getDefaultRowPrefetch();