commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthew Denson" <mden...@dayspring-tech.com>
Subject commons-dbcp/Oracle 8i/ResultSet.TYPE_SCROLL_INSENSITIVE getting unexpected exception
Date Thu, 15 May 2003 23:29:01 GMT
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
------------------------------------------------------------------------
------

Mime
View raw message