commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reid Pinchback <rei...@yahoo.com>
Subject RE: [DBCP] per-user pooling with Oracle JDBC thin driver
Date Wed, 20 Oct 2004 17:54:51 GMT
Last I looked (a couple of years ago), Oracle drivers
maintained an open stream connection of some sort for
clobs, maybe the commit causes the driver to close 
such streams?  You could test that by writing code
directly against the Oracle driver, e.g. first getting
a reference to a CLOB, doing a commit, and then seeing
what happened afterwards.

--- Chris Nappin <C.Nappin@abm-uk.com> wrote:

> Hi,
> 
>   I've managed to get a little further by adding a
> "connection.commit()"
> call after all SELECT queries (we were only
> committing UPDATEs and
> INSERTs, not reads) which is a nasty workaround but
> needed since I can't
> have a read-only data-source.
> 
> However, I'm now getting some *really* odd errors in
> our Clob-handling
> code:
> 
> java.sql.Clob realClob = rs.getClob(1);
> System.out.println("realClob classname is: " +
> realClob.getClass().getName());
>         
> if (realClob instanceof oracle.sql.CLOB) {
> 	System.out.println("realClob is a
> oracle.sql.CLOB");
> } else {
> 	System.out.println("realClob is NOT a
> oracle.sql.CLOB");
> }
> oracle.sql.CLOB clob = (oracle.sql.CLOB) realClob; 
> 
> This code prints out a classname of
> "oracle.sql.CLOB", but instanceof
> fails and the last line produces a
> ClassCastException!
> 
> That's really weird and shouldn't be possible in
> Java (getClass is final
> so can't every contradict instanceof)????
> 
> Everything works fine using direct connections
> though, it's only when
> using DBCP that I get the above error. Does DBCP use
> wrapped Connections
> and ResultSets? I've tried Oracle JDBC 9.2.0.1.0 and
> 9.2.0.5.0 (buggy
> but matches our dbms version) drivers, both give
> this error.
> 
> Cheers,
> 
>    Chris Nappin
> 
> -----Original Message-----
> From: Chris Nappin 
> Sent: 18 October 2004 15:03
> To: commons-user@jakarta.apache.org
> Subject: [DBCP] per-user pooling with Oracle JDBC
> thin driver
> 
> Hi,
> 
>  
> 
>   I'm trying to configure per-user connection
> pooling with Tomcat, DBCP
> and the Oracle 9i JDBC driver. A connection with
> default driver settings
> seems to work, but when setting auto-commit to false
> I get errors. I've
> tried DBCP 1.1 and 1.2.1 (with Pool 1.1 or 1.2).
> 
>  
> 
> I have configured DBCP as follows (Tomcat server.xml
> extracts):
> 
>  
> 
> <Resource name="jdbc/omsdev" auth="Container"
> 
>  
>
type="org.apache.commons.dbcp.datasources.PerUserPoolDataSource"/>
> 
>             <ResourceParams name="jdbc/omsdev">
> 
>             <parameter>
> 
>             <name>factory</name>
> 
>  
>
<value>org.apache.commons.dbcp.datasources.PerUserPoolDataSourceFactory<
> /value>
> 
>         </parameter>
> 
>         <parameter>
> 
>             <name>dataSourceName</name>
> 
>                        
> <value>java:comp/env/jdbc/CPDS</value>
> 
>             </parameter>
> 
>             <parameter>
> 
>                         <name>maxActive</name>
> 
>                         <value>10</value>
> 
>             </parameter>
> 
>             <parameter>
> 
>                         <name>maxIdle</name>
> 
>                         <value>2</value>
> 
>             </parameter>
> 
>             <parameter>
> 
>                         <name>maxWait</name>
> 
>                         <value>-1</value>
> 
>             </parameter>
> 
>             <parameter>
> 
>             <name>defaultReadOnly</name>
> 
>                         <value>false</value>
> 
>             </parameter>
> 
>             <parameter>
> 
>             <name>defaultAutoCommit</name>
> 
>                         <value>false</value>
> 
>             </parameter>
> 
>             </ResourceParams>
> 
>  
> 
> This then uses the CPDS driver-wrapper, configured
> as follows (i.e. no
> username or password):
> 
>  
> 
> <Resource name="jdbc/CPDS" auth="Container" 
> 
>  
>
type="org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS"/>
>      
> 
>             <ResourceParams name="jdbc/CPDS">
> 
>             <parameter>
> 
>                         <name>factory</name>
> 
>  
>
<value>org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS</value>
> 
>             </parameter>
> 
>             <parameter>
> 
>                         <name>driver</name>
> 
>                        
> <value>oracle.jdbc.driver.OracleDriver</value>
> 
>             </parameter>
> 
>             <parameter>
> 
>                         <name>url</name>
> 
>                         <value>..my connection
> string..</value>
> 
>             </parameter>
> 
>             </ResourceParams>
> 
>  
> 
>  
> 
> I'm then using the following code to open a
> connection (name is
> "jdbc/omsdev", user is a bean populated on login):
> 
>  
> 
> Context initContext = new InitialContext();
> 
> DataSource ds = (DataSource)
> initContext.lookup("java:comp/env/" 
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message