You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Matthew Denson <md...@dayspring-tech.com> on 2003/05/16 01:29:01 UTC

commons-dbcp/Oracle 8i/ResultSet.TYPE_SCROLL_INSENSITIVE getting unexpected exception

I am having trouble with one of my projects.  I have spent the day
switching over to commons-dbcp as the connection pool.  It is working
fine in most circumstances but I have trouble when I need a scrollable
ResultSet.  I've included the Object I am using to set up the pool and
run a test to make sure everything is good.  When I try to call last on
ResultSet is throws the exception also included below.

I am using the version of commons-dbcp and commons-pool included with
Struts 1.1 RC1.  The Oracle driver is the Oracle thin driver in
Classes12.zip dated 4/13/2000.  The scrollable ResultSet worked with the
previous ConnectionPool.  

I'm expecting that something in my configuration is causing this to
happen.  If you could shed any light on this that would be wonderful.
I've tried to be comprehensive, but if I need to provide something else
please let me know.

Thanks in an advance.

All the best,
Matthew

------------------------------------------------------------------------
-----------
Source that has trouble
------------------------------------------------------------------------
-----------
public class ConnectionPool {
    private static Log log = LogFactory.getLog(ConnectionPool.class);
    // Single broker to be shared
    // by all other Servlets
    public static DataSource ds;

    public ConnectionPool(Properties props) throws Exception {
        PropertiesHelper p = new PropertiesHelper(props);

        DriverAdapterCPDS cpds = new DriverAdapterCPDS();
 
cpds.setDriver(p.getProperty("torque.dsfactory.efaerp.connection.driver"
));
 
cpds.setUrl(p.getProperty("torque.dsfactory.efaerp.connection.url"));

        Jdbc2PoolDataSource tds = new Jdbc2PoolDataSource();
        tds.setConnectionPoolDataSource(cpds);
 
tds.setDefaultMaxActive(p.getIntegerProperty("torque.dsfactory.efaerp.po
ol.defaultMaxActive"));
        tds.setDefaultMaxWait(50);
 
tds.setTestOnBorrow(p.getBooleanProperty("torque.dsfactory.efaerp.pool.t
estOnBorrow"));
 
tds.setValidationQuery(p.getProperty("torque.dsfactory.efaerp.pool.valid
ationQuery"));

        ds = tds;

        // run a test
        Connection conn = null;
        PreparedStatement stmt = null;
        ResultSet rset = null;
        try {
            conn = ds.getConnection();
            stmt = conn.prepareStatement(
 
p.getProperty("torque.dsfactory.efaerp.pool.validationQuery"),
                    ResultSet.TYPE_SCROLL_INSENSITIVE,
                    ResultSet.CONCUR_READ_ONLY);
            rset = stmt.executeQuery();
            rset.last();
        } finally {
            try { rset.close(); } catch(Exception e) { }
            try { stmt.close(); } catch(Exception e) { }
            try { conn.close(); } catch(Exception e) { }
        }
    }
}
------------------------------------------------------------------------
-------
Exception
------------------------------------------------------------------------
-------
java.sql.SQLException: Invalid operation for forward only resultset :
last
	at
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
	at
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:156)
	at oracle.jdbc.driver.BaseResultSet.last(BaseResultSet.java:75)
	at
com.efafunding.lib.jdbc.ConnectionPool.<init>(ConnectionPool.java:85)
	at com.efafunding.servlets.AppServlet.init(AppServlet.java:69)
	at
allaire.jrun.servlet.JRunServletLoader.loadServletInstance(JRunServletLo
ader.java:236)
....
------------------------------------------------------------------------
------
Excerpt from properties file
------------------------------------------------------------------------
------
torque.dsfactory.efaerp.connection.driver=oracle.jdbc.driver.OracleDrive
r
torque.dsfactory.efaerp.connection.url=jdbc:oracle:thin:DEV/dev@joel:152
1:EFAD
torque.dsfactory.efaerp.pool.defaultMaxActive=5
torque.dsfactory.efaerp.pool.testOnBorrow=true
torque.dsfactory.efaerp.pool.validationQuery=SELECT 1 FROM DUAL
------------------------------------------------------------------------
------