tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jimmy Ray <jimmyra...@yahoo.com>
Subject Re: DBCP/JDBC Problems with DelegatingResultSet
Date Tue, 12 Apr 2005 15:26:51 GMT
Do you mean that perhaps you are trying to access
SYBASE specific JDBC extensions?  If so, then you need
the "inner most delegate" connection.  I did this with
Oracle:

I also had this parameter in my JNDI declaration in
the server.xml...

<parameter>
       
<name>accessToUnderlyingConnectionAllowed</name>
        <value>true</value>
      </parameter>

Then I used this static method that I wrote.  Just
pass in the JNDI data source name.  BUT...be careful,
DO NOT close this underlying connection, or your next
call will have the overhead of recreating the
underlying connection object for DBCP:

public static synchronized Connection
getDelegatingConnection(
            String dataSource) throws
SQLException,NamingException,Exception {
        
        final String JNDI_LOOKUP = "java:comp/env";
        
        Connection conn = null;
        OracleConnection oc = null;
        
        Context initCtx = new InitialContext();
        Context envCtx = (Context)
initCtx.lookup(JNDI_LOOKUP);
        
        if (envCtx == null) {
            throw new Exception("No
EnvironmentContextException");
        }
        
        DataSource ds = (DataSource)
envCtx.lookup(dataSource);
        if (ds == null) {
            throw new Exception("No
DatasourceException");
        }
        
        ((BasicDataSource)
ds).setAccessToUnderlyingConnectionAllowed(true);
                
        conn = ds.getConnection();
        if (conn == null) {
            throw new Exception("No
ConnectionException");
        } 

        Connection dconn = ((DelegatingConnection)
conn).getInnermostDelegate();

        if (dconn == null) {
            throw new Exception("No
DelegatingConnectionException");
        }
        
        conn.close();
        conn=null;

        return dconn;
    }

Regards,

Jimmy Ray
--- Sebastian.Wiemer@gfk.de wrote:
> 
> 
> 
> 
> Hello,
> 
> I need some help accessing low level routines using
> JDNI based connection
> pooling provided by tomcat.
> 
> Environment:      J2SE 1.4.2
> Tomcat:     5.5
> JDBC-Driver:      Sybase JConnect 5.5 (TDS)
> 
> The Tomcat is configured to provide a small
> connection pool.
> 
> Within my servlet i need access to the low-level
> implementation of the
> ResultSet from Sybase.
> The problem is, that the following code:
> 
> Connection conn = dataSource.getConnection();
> Statement stmt = conn.getConnection();
> ResultSet result = stmt.executeQuery( "..." );
> 
> System.out.println( result.getClass().getName() );
> 
> prints
> org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.
> 
> I couldn't find a api documentation for this class
> nor could i find the jar
> file providing this class
> at all in the tomcat installation directory.
> 
> Can anyone give a hint in which JAR archive this
> class can be found ?
> 
> 
> 
> Mit freundlichen Grüßen / Kind regards
> Sebastian Wiemer
> 
> ------------------------------------
> Sebastian Wiemer
> GfK Group
> Data Services GmbH
> Nordwestring 101
> D-90319 Nürnberg
> Fon: +49 (0) 911 395 3876
> Fax: +49 (0) 911 333 796
> sebastian.wiemer@gfk.de
> www.gfk.de / www.gfk.com
> ------------------------------------
> 
> 
> 
> _________________________
> 
> Diese E-Mail (ggf. nebst Anhang) enthält
> vertrauliche und/oder rechtlich
> geschützte Informationen. Wenn Sie nicht der
> richtige Adressat sind, oder
> diese E-Mail irrtümlich erhalten haben, informieren
> Sie bitte sofort den
> Absender und vernichten Sie diese Mail. Das
> unerlaubte Kopieren sowie die
> unbefugte Weitergabe dieser Mail ist nicht
> gestattet.
> 
> This e-mail (and any attachment/s) contains
> confidential and/or privileged
> information. If you are not the intended recipient
> (or have received this
> e-mail in error) please notify the sender
> immediately and destroy this
> e-mail. Any unauthorised copying, disclosure or
> distribution of the
> material in this e-mail is strictly forbidden.
> _________________________
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tomcat-user-help@jakarta.apache.org
> 
> 


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/

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


Mime
View raw message