You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Zdeněk Vráblík <zd...@vrablik.org> on 2007/05/11 19:41:36 UTC

Oracle JDBC connection Tomcat 5.5

Hi all,

I am configuring jdbc datasources on Tomcat 5.5.23.

I followed this document to configure orcle database with Tomcat
http://www.microdeveloper.com/html/JNDI_Orcl_Tomcat1p.html

I am not able to see datasource in web admin.
datasource 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"/>

Everything works fine with this 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"/>

I need get OracleConnection instead of Connection.

There is not any error or exception in log files.
I have ojdbc14.jar in common/lib directory.
I am able to use even Oracle JGeometry objects with common Connection,
but I need OracleConnection.

My configuration:
Windows XP,
JDK  5_09
Tomcat 5.5.23
Oracle 10G 10.2.0.1

Do you have any idea, what I am doing wrong?
How could I get any error or exception? Logs in tomcat/logs dirrectory
are correct. I have there only info outputs from my test application.

Thanks.

Regards,
Zdenek Vrablik

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Oracle JDBC connection Tomcat 5.5

Posted by Zdeněk Vráblík <zd...@vrablik.org>.
Hi all,

unfortunately this solution shouldn't be used.

The dConn connection mustn't be closed directly, but the original
connection from datasource should be closed.

...

Regards,
Zdenek

On 5/14/07, Zdeněk Vráblík <zd...@vrablik.org> wrote:
> 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 <zd...@vrablik.org> 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 <mg...@hotmail.com> 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" <ra...@gmail.com>
> > > To: "Tomcat Users List" <us...@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 <zd...@vrablik.org> 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: users-unsubscribe@tomcat.apache.org
> > > For additional commands, e-mail: users-help@tomcat.apache.org
> > >
> > >
> >
>

Re: Oracle JDBC connection Tomcat 5.5

Posted by Zdeněk Vráblík <zd...@vrablik.org>.
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 <zd...@vrablik.org> 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 <mg...@hotmail.com> 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" <ra...@gmail.com>
> > To: "Tomcat Users List" <us...@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 <zd...@vrablik.org> 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: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>

Re: Oracle JDBC connection Tomcat 5.5

Posted by Martin Gainty <mg...@hotmail.com>.
configuration options for
BasicDataSource and
PerUserPoolDataSource
are located at
http://wiki.apache.org/jakarta-commons/DBCP

HTH/
Martin
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: "Zdeněk Vráblík" <zd...@vrablik.org>
To: "Tomcat Users List" <us...@tomcat.apache.org>; "Martin Gainty" 
<mg...@hotmail.com>
Sent: Monday, May 14, 2007 6:57 AM
Subject: Re: Oracle JDBC connection Tomcat 5.5


> 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 <mg...@hotmail.com> 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" <ra...@gmail.com>
>> To: "Tomcat Users List" <us...@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 <zd...@vrablik.org> 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: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Oracle JDBC connection Tomcat 5.5

Posted by Zdeněk Vráblík <zd...@vrablik.org>.
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 <mg...@hotmail.com> 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" <ra...@gmail.com>
> To: "Tomcat Users List" <us...@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 <zd...@vrablik.org> 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: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Oracle JDBC connection Tomcat 5.5

Posted by Martin Gainty <mg...@hotmail.com>.
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" <ra...@gmail.com>
To: "Tomcat Users List" <us...@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 <zd...@vrablik.org> 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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Oracle JDBC connection Tomcat 5.5

Posted by Rashmi Rubdi <ra...@gmail.com>.
On 5/12/07, Zdeněk Vráblík <zd...@vrablik.org> 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

Re: Oracle JDBC connection Tomcat 5.5

Posted by Zdeněk Vráblík <zd...@vrablik.org>.
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
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



On 5/12/07, Rashmi Rubdi <ra...@gmail.com> wrote:
> On 5/11/07, Zdeněk Vráblík <zd...@vrablik.org> wrote:
> > Hi all,
> >
> > I am configuring jdbc datasources on Tomcat 5.5.23.
> >
> > I followed this document to configure orcle database with Tomcat
> > http://www.microdeveloper.com/html/JNDI_Orcl_Tomcat1p.html
>
> Sorry I didn't go through the instructions in the above link , I would
> follow the instructions for Oracle 10g here:
> http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> look for the title: Oracle 8i, 9i & 10g
>
>
> > I am not able to see datasource in web admin.
> > datasource 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"/>
> >
> > Everything works fine with this 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"/>
> >
> > I need get OracleConnection instead of Connection.
>
> I think you also need classes12.jar
>
> >
> > There is not any error or exception in log files.
> > I have ojdbc14.jar in common/lib directory.
> > I am able to use even Oracle JGeometry objects with common Connection,
> > but I need OracleConnection.
> >
> > My configuration:
> > Windows XP,
> > JDK  5_09
> > Tomcat 5.5.23
> > Oracle 10G 10.2.0.1
> >
> > Do you have any idea, what I am doing wrong?
>
> Most likely you need Oracle's classes12.jar
>
> > How could I get any error or exception? Logs in tomcat/logs dirrectory
> > are correct. I have there only info outputs from my test application.
> >
> > Thanks.
> >
> > Regards,
> > Zdenek Vrablik
> >
>
> Regards
> Rashmi
>

Re: Oracle JDBC connection Tomcat 5.5

Posted by Rashmi Rubdi <ra...@gmail.com>.
On 5/11/07, Zdeněk Vráblík <zd...@vrablik.org> wrote:
> Hi all,
>
> I am configuring jdbc datasources on Tomcat 5.5.23.
>
> I followed this document to configure orcle database with Tomcat
> http://www.microdeveloper.com/html/JNDI_Orcl_Tomcat1p.html

Sorry I didn't go through the instructions in the above link , I would
follow the instructions for Oracle 10g here:
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
look for the title: Oracle 8i, 9i & 10g


> I am not able to see datasource in web admin.
> datasource 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"/>
>
> Everything works fine with this 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"/>
>
> I need get OracleConnection instead of Connection.

I think you also need classes12.jar

>
> There is not any error or exception in log files.
> I have ojdbc14.jar in common/lib directory.
> I am able to use even Oracle JGeometry objects with common Connection,
> but I need OracleConnection.
>
> My configuration:
> Windows XP,
> JDK  5_09
> Tomcat 5.5.23
> Oracle 10G 10.2.0.1
>
> Do you have any idea, what I am doing wrong?

Most likely you need Oracle's classes12.jar

> How could I get any error or exception? Logs in tomcat/logs dirrectory
> are correct. I have there only info outputs from my test application.
>
> Thanks.
>
> Regards,
> Zdenek Vrablik
>

Regards
Rashmi