tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i...@projektinter.net
Subject Re: Connection pooling doesn't work for me ... Help !!
Date Thu, 13 Jun 2002 20:38:49 GMT
Thanks for your answer. That looks rather unconventional ;)

Rainer



> I apologize but I saw this post late. I had a problem with connection
> pooling using Oracle and JNDI. To get around it I had to do something like
> this:
>
> In conf\server.xml
>
> <Resource name="jdbc/mydb" auth="Container"
> type="oracle.jdbc.pool.OracleConnectionPoolDataSource" />
>    <ResourceParams name="jdbc/mydb">
>       <parameter>
>          <name>user</name>
>          <value>user</value>
>        </parameter>
>         <parameter>
>            <name>password</name>
>            <value>password</value>
>         </parameter>
>         <parameter>
>            <name>driverClassName</name>
>            <value>oracle.jdbc.driver.OracleDriver</value>
>          </parameter>
>          <parameter>
>              <name>driverName</name>
>              <value>jdbc:oracle:thin:@oracle.ds:1521:db</value>
>         </parameter>
>  </ResourceParams>
>
> In WEB-INF/web.xml
>
> <web-app>
>
>    <servlet>
>       <servlet-name>OracleConnectionPool</servlet-name>
>       <servlet-class>aOracleConnectionPool</servlet-class>
>       <load-on-startup>1</load-on-startup>
>    </servlet>
>
>    <resource-ref>
>       <res-ref-name>jdbc/mydb</res-ref-name>
>       <res-type>oracle.jdbc.pool.OracleConnectionPoolDataSource</res-type>
>       <res-auth>Container</res-auth>
>    </resource-ref>
>
> </web-app>
>
> OracleConnectionPool.java
>
> try {
> Context initCtx = new InitialContext();
> OracleConnectionPoolDataSource ocpds = new
> OracleConnectionPoolDataSource();
> ResourceBundle rb = ResourceBundle.getBundle("database");
> ocpds.setURL(rb.getString("url"));
> ocpds.setUser(rb.getString("user"));
> ocpds.setPassword(rb.getString("password"));
> initCtx.rebind("axesdb", ocpds);
> } catch (SQLException sqlex) {
> sqlex.printStackTrace();
> } catch (Exception ex) {
> ex.printStackTrace();
> }
>
> In your code:
>
> Context initCtx = new InitialContext();
> OracleConnectionPoolDataSource ocpds =
> (OracleConnectionPoolDataSource)initCtx.lookup("mydb");
> PooledConnection pooledConnection = ocpds.getPooledConnection();
> Connection connection = pooledConnection.getConnection();
> Statement statement = connection.createStatement();
> ResultSet resultSet = statement.executeQuery(sql);
>
> Good Luck!
>
> Kevin
>
> Kevin Andryc
> Web Systems Engineer
> MISER
> http://www.umass.edu/miser/
> Phone: (413)-545-3460
> kandryc@miser.umass.edu
>
>
>
> -----Original Message-----
> From: info@projektinter.net [mailto:info@projektinter.net]
> Sent: Thursday, June 13, 2002 03:12 PM
> To: Tomcat Users List
> Subject: Re: Connection pooling doesn't work for me ... Help !!
>
> Hi,
>
> well I got stuck with the same problem as the others:
> I cannot get a connect to the DB via JNDI.
>
> Just a simple idea: can the problem be the MySQL Driver?
> Is there maybe someone out there to give some hints how to look into this
> "blackbox" JNDI to see what is going wrong(Craig ?)
>
> Thanks for any help!
>
> Rainer
>
> ----- Original Message -----
> From: "Neil Milne" <ngm@orange.net>
> To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
> Sent: Thursday, June 13, 2002 2:56 PM
> Subject: Re: Connection pooling doesn't work for me ... Help !!
>
>
> > I'm using the JNDI Datasource setup fine with Tomcat 4.0.3 and Sybase.
> > In server.xml I have:
> >
> > <Resource name="jdbc/db" auth="Container"
> > type="javax.sql.ConnectionPoolDataSource"/>
> > <ResourceParams name="jdbc/db">
> >     <parameter> <name>driverClassName</name>
> > <value>com.sybase.jdbc2.jdbc.SybDriver</value> </parameter>
> >     <parameter> <name>user</name> <value>user</value></parameter>
> > <!-- other driver specific db params... -->
> >     <parameter> <name>initialPoolSize</name>
<value>5</value></parameter>
> > </ResourceParams>
> >
> > There's no need to specify a factory as Tomcat has a Datasource resource
> > factory built in.
> >
> > Note that I've used the ConnectionPoolDataSource class - not sure if
> > this makes a difference.
> >
> > HTH
> > Neil.
> >
> > ----- Original Message -----
> > from: Martin Jacobson <martin_j@libero.it>
> > date: Thursday, June 13, 2002 1:40 pm
> > subject: Re: Connection pooling doesn't work for me ... Help !!
> >
> > > anthony.dodd wrote:
> > >
> > > > Hi
> > > >
> > > >     I've posted a solution see "Generic DataSource Resource Factory
> > > > Available. JDBC Data Source" on the tomcat user maillist.
> > > >
> > > > Tony
> > > >
> > > Yes, but...
> > >
> > >
> > > Like many others on this list, I too have been unable to get the
> > > std
> > > JNDI DataSource thingy working; as an interim measure, I
> > > implemented a
> > > workaround (which does at least work!), but I refuse to be defeated!
> > >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> <mailto:tomcat-user-help@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
> <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:tomcat-user-help@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:tomcat-user-help@jakarta.apache.org>
>
>


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


Mime
View raw message