Hi Martin,

I have solution.

There is resource JDBC configuration which works for Tomcat 5.5.23
<Resource name="jdbcRes"
         auth="Container"
                  type="javax.sql.DataSource"
                  factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
         username="user"
         password="user"
         driverClassName="oracle.jdbc.OracleDriver"
         url="jdbc:oracle:thin:@192.168.100.119:1521:orcl"
                  accessToUnderlyingConnectionAllowed="true"
         maxActive="20" maxIdle="10" maxwait="-1"/>


When is set accessToUnderlyingConnectionAllowed to true DataSource produce
connection which implement DelegatingConnection interface.

DataSource ds = (DataSource) ctxt.lookup(poolName);
   conn       = ds.getConnection();
   Connection dconn = ((DelegatingConnection) conn).getInnermostDelegate();

dconn is OracleConnection.

There musn't be library commons-dbcp*.jar in common/lib directory,
because all classes are in jar naming-factory-dbcp.jar in package
org.apache.tomcat.dbcp.dbcp.

Thanks Rashmi and Martin for help.

Regards,
Zdenek

On 5/14/07, Zdeněk Vráblík <[EMAIL PROTECTED]> wrote:
Hi Martin,

thanks for help.
I have tried your suggestion and it works fine - I am able to get
OracleConnection.
(I had to change String c_sUserNameKey="username"; to String
c_sUserNameKey="user";)

It works for common Connection, but I need OracleConnection interface.
jdbc configuration:
<Resource name="sisPool"
         auth="Container"
         type="javax.sql.DataSource"
                 factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
         username="USER_51319"
         password="USER_51319"
         driverClassName="oracle.jdbc.driver.OracleDriver"  or
driverClassName="oracle.jdbc.driver.OracleDriver"
         url="jdbc:oracle:thin:@192.168.100.119:1521:orcl"
         maxActive="20" maxIdle="10" maxwait="-1"/>

But the datasource is not found if I use this configuration:
<Resource name="sisPool"
          auth="Container"
          type="oracle.jdbc.pool.OracleDataSource"
          factory="oracle.jdbc.pool.OracleDataSourceFactory"
          username="ISMART_USER_51319"
          password="ISMART_USER_51319"
          driverClassName="oracle.jdbc.OracleDriver"
          url="jdbc:oracle:thin:@192.168.100.119:1521:orcl"
          maxActive="20" maxIdle="10" maxwait="-1"/>

I have found in dbcp configuration other way to get inner connection:
Connection conn = ds.getConnection();
    Connection dconn = ((DelegatingConnection) conn).getInnermostDelegate();

but when I get connection from Tomcat it doesn't implement
DelegatingConnection interface.

initContext = new InitialContext();
envContext  = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource) ctxt.lookup(poolName);
 conn       = ds.getConnection();

I am not able to find any way how to get OracleConnection instead Connection.

Do you have any idea?

Thanks.

Regards,
Zdenek

On 5/13/07, Martin Gainty <[EMAIL PROTECTED]> wrote:
> make sure the driver is ok first e.g.
> import java.sql.*;
>
> Properties props = new Properties();
> String c_sUserNameKey="username";
> String c_sPasswordKey="password";
> String c_sDBURL ="jdbc:oracle:thin:@";
> String c_sDriverName ="oracle.jdbc.driver.OracleDriver";
>
> //Instantiate driver
> Driver c_Driver=null;
> try
> {
>    c_Driver = (Driver)Class.forName( c_sDriverName ).newInstance();
> }
> catch(SQLException sqle)
> {
>  System.out.println("Cannot instantiate driver ..is it right version..is it
> on classpath?");
>  return;
> }
> //make sure Oracle listenet is operational (netstat -a | grep 1521)
> //make SURE Oracle DB is up and listening (tnsping SID) returns successful
> //make sure you acquire the username/password to establish connection to
> oracle db
> //place username,password into properties
> props.put( c_sUserNameKey, c_sDBUser );
> props.put( c_sPasswordKey, c_sDBPassword );
>
> //Get a connection
> try
> {
>     Connection = c_Driver.connect( c_sDBURL, props );
> }
> catch ( SQLException sqlex )
> {
>             System.out.println( "Error connecting to database", sqlex );
>             return;
>  }
>
> //should get you started..
> M--
> This email message and any files transmitted with it contain confidential
> information intended only for the person(s) to whom this email message is
> addressed.  If you have received this email message in error, please notify
> the sender immediately by telephone or email and destroy the original
> message without making a copy.  Thank you.
>
> ----- Original Message -----
> From: "Rashmi Rubdi" <[EMAIL PROTECTED]>
> To: "Tomcat Users List" <users@tomcat.apache.org>
> Sent: Sunday, May 13, 2007 3:23 PM
> Subject: Re: Oracle JDBC connection Tomcat 5.5
>
>
> > On 5/12/07, Zdeněk Vráblík <[EMAIL PROTECTED]> wrote:
> >> Hi Rashmi,
> >>
> >> thans for reply.
> >>
> >> Configuration that is described in link you sent me works fine.
> >> Problem is when I change
> >> the datasource factory to Oracle datasource factory. Than is not
> >> possible to find this datasource through JNDI lookup and this
> >> connection disappear from admin console.
> >> I think that ojdbc14.jar is newer version of oracle drivers  and it
> >
> > You are right, sorry you don't need classes12.jar in this case please
> > ignore my previous post.
> >
> > I also happen to have oracle 10g, in order to answer your question, I
> > was trying to see if I could set up a connection pool and then try to
> > get OracleConnection instead of SQL Connection, I tried for almost 1/2
> > a day so far, to get things set up but got an error
> > "java.sql.SQLException: No more data to read from socket" that is
> > taking too long to figure out, even after searching for answers on the
> > Internet. I have other things to do :-) so I will give up on this for
> > now.
> >
> > Anyway, there's some more instructions here :
> > 
http://www.oracle.com/technology/sample_code/tech/java/oc4j/htdocs/jdbc_in_j2ee/jdbc_in_j2ee.html
> >
> > the above instructions are written for Oracle9iAS Container and not
> > Tomcat, however they demonstrate how to obtain OracleConnection ----
> > may be you'll find some useful information there unless someone on
> > this list has a solution.
> >
> > You may also want to check with Oracle's Technology Forums.
> >
> >> works fine with standard datasource factory
> >> org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory and
> >> javax.sql.DataSource. It stops work when I use oracle datasource
> >> factory
> >>  factory="oracle.jdbc.pool.OracleDataSourceFactory" and datasource type
> >> type="oracle.jdbc.pool.OracleDataSource".
> >>
> >> What I need is any solution how get OracleConnection instead of
> >> Connection to use.
> >> Do I miss any parameter in resource configuration?
> >> <Resource name="sisPool"
> >>            auth="Container"
> >>            type="oracle.jdbc.pool.OracleDataSource"
> >>            factory="oracle.jdbc.pool.OracleDataSourceFactory"
> >>            username="USER_51319"
> >>            password="USER_51319"
> >>            driverClassName="oracle.jdbc.OracleDriver"
> >>            url="jdbc:oracle:thin:@192.168.100.119:1521:orcl"
> >>            maxActive="20" maxIdle="10" maxwait="-1"/>
> >>
> >> Thanks.
> >> Zdenek
> >>
> >
> > -Regards
> > Rashmi
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to