Absolute Guide for config of JDBC Connection Pool ?

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Absolute Guide for config of JDBC Connection Pool ?

jack-24
There seems to be 'truckloads' of information on just as many forums on how best to setup a JDBC connection pool, varying from which file to put what entries (server.xml, context.xml, web.xml) etc....
   
  It looks like the same questions be asked in a slightly different fashion and for different environments.
   
  Does anyone happen to know where there is a definative guide on how to do this and what jar files one needs ?... or does this sort of 'clean doc'  not exist ?
   
  FYI: My environment: Tomcat 5.5.9, Sybase, Windows .
  Many thanks!

               
---------------------------------
Yahoo! Photos – Showcase holiday pictures in hardcover
 Photo Books. You design it and we’ll bind it!
Reply | Threaded
Open this post in threaded view
|

RE: Absolute Guide for config of JDBC Connection Pool ?

Caldarale, Charles R
> From: g m [mailto:[hidden email]]
> Subject: Absolute Guide for config of JDBC Connection Pool ?
>
>   Does anyone happen to know where there is a definative
> guide on how to do this and what jar files one needs ?

There obviously won't be a single doc covering all databases - there are
just too many of them.

Have you looked here?
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.h
tml

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Absolute Guide for config of JDBC Connection Pool ?

Len Popp
In reply to this post by jack-24
I don't know if there's a complete top-to-bottom guide, but here's
what I know from setting up connection pooling under 5.5.12:

1. The JDBC driver JAR must go in the common/lib directory (because
for connection pooling it needs to be accessible to both Tomcat and
the web app).

2. DBCP is built into Tomcat so you don't need to install a JAR for that.

3. The <Resource> tag goes inside the <Context> tag for the web app,
wherever it is (server.xml, webapps/<app>/META-INF/context.xml or
conf/Catalina/localhost/<app>.xml)
Note that the syntax for <Resource> has changed from earlier versions
– see the Tomcat documentation. Here's a sample:

<Resource name="jdbc/???"
    type="javax.sql.DataSource"
    auth="Container"
    driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/???"
    username="???"
    password="???"
    maxIdle="15"
    maxActive="50"
    maxWait="10000"
    factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
    removeAbandoned="true"
    removeAbandonedTimeout="60"
    logAbandoned="true"/>

The "???" bits are installation-dependent. Some of the parameters will
be different for Sybase (driverClassName and url for sure).

4. Yes, it is supposed to say "... .dbcp.dbcp ..." in the factory= line.

5. The code to get a DB connection is:
    InitialContext initCtx = new InitialContext();
    DataSource ds = (DataSource) initCtx.lookup("java:comp/env/jdbc/???");
    Connection conn = ds.getConnection();
Make sure that "jdbc/???" is the same here as in the <Resource> tag.

6. Always close the connection when you're done with it. Use a
"finally" block to make sure.

7. If you're trying to decide where to put the <Context> declaration,
the choices are:
- server.xml – Don't put it here. We're told it's bad.
- webapps/<app>/META-INF/context.xml – If you put it here, it will be
bundled up in the app's WAR file. That makes it easier to install, but
harder to configure if every installation has different details for
the database <Resource> tag.
- conf/Catalina/localhost/<app>.xml – If you put it here, it's easier
to edit the <Resource> tag, but it's an extra file to be installed in
addition to the WAR.

Hope this helps. At least it's shorter than
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html.
:-)

On 1/19/06, g m <[hidden email]> wrote:
> There seems to be 'truckloads' of information on just as many forums on how best to setup a JDBC connection pool, varying from which file to put what entries (server.xml, context.xml, web.xml) etc....
>
>   It looks like the same questions be asked in a slightly different fashion and for different environments.
>
>   Does anyone happen to know where there is a definative guide on how to do this and what jar files one needs ?... or does this sort of 'clean doc'  not exist ?
>
>   FYI: My environment: Tomcat 5.5.9, Sybase, Windows .
>   Many thanks!

--
Len
Reply | Threaded
Open this post in threaded view
|

RE: Absolute Guide for config of JDBC Connection Pool ?

Bernie Durfee
In reply to this post by jack-24
Excellent! That is the exact documentation that should be on the Tomcat
site. It would also be nice to see a quick description of how Tomcat
processes the <Resource> sections, what exactly it does with the
attributes, so that other drivers and pools can be configured.

There are also other parameters that DBCP accepts...

http://jakarta.apache.org/commons/dbcp/configuration.html

Bernie Durfee



> -----Original Message-----
> From: Len Popp [mailto:[hidden email]]
> Sent: Thursday, January 19, 2006 12:58 PM
> To: Tomcat Users List
> Subject: Re: Absolute Guide for config of JDBC Connection Pool ?
>
>
> I don't know if there's a complete top-to-bottom guide, but here's
> what I know from setting up connection pooling under 5.5.12:
>
> 1. The JDBC driver JAR must go in the common/lib directory (because
> for connection pooling it needs to be accessible to both Tomcat and
> the web app).
>
> 2. DBCP is built into Tomcat so you don't need to install a
> JAR for that.
>
> 3. The <Resource> tag goes inside the <Context> tag for the web app,
> wherever it is (server.xml, webapps/<app>/META-INF/context.xml or
> conf/Catalina/localhost/<app>.xml)
> Note that the syntax for <Resource> has changed from earlier versions
> - see the Tomcat documentation. Here's a sample:
>
> <Resource name="jdbc/???"
>     type="javax.sql.DataSource"
>     auth="Container"
>     driverClassName="com.mysql.jdbc.Driver"
>     url="jdbc:mysql://localhost:3306/???"
>     username="???"
>     password="???"
>     maxIdle="15"
>     maxActive="50"
>     maxWait="10000"
>     factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
>     removeAbandoned="true"
>     removeAbandonedTimeout="60"
>     logAbandoned="true"/>
>
> The "???" bits are installation-dependent. Some of the parameters will
> be different for Sybase (driverClassName and url for sure).
>
> 4. Yes, it is supposed to say "... .dbcp.dbcp ..." in the
> factory= line.
>
> 5. The code to get a DB connection is:
>     InitialContext initCtx = new InitialContext();
>     DataSource ds = (DataSource)
> initCtx.lookup("java:comp/env/jdbc/???");
>     Connection conn = ds.getConnection();
> Make sure that "jdbc/???" is the same here as in the <Resource> tag.
>
> 6. Always close the connection when you're done with it. Use a
> "finally" block to make sure.
>
> 7. If you're trying to decide where to put the <Context> declaration,
> the choices are:
> - server.xml - Don't put it here. We're told it's bad.
> - webapps/<app>/META-INF/context.xml - If you put it here, it will be
> bundled up in the app's WAR file. That makes it easier to install, but
> harder to configure if every installation has different details for
> the database <Resource> tag.
> - conf/Catalina/localhost/<app>.xml - If you put it here, it's easier
> to edit the <Resource> tag, but it's an extra file to be installed in
> addition to the WAR.
>
> Hope this helps. At least it's shorter than
> http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-exampl
es-howto.html.
:-)

On 1/19/06, g m <[hidden email]> wrote:
> There seems to be 'truckloads' of information on just as many forums
on how best to setup a JDBC connection pool, varying from which file to
put what entries (server.xml, context.xml, web.xml) etc....
>
>   It looks like the same questions be asked in a slightly different
fashion and for different environments.
>
>   Does anyone happen to know where there is a definative guide on how
to do this and what jar files one needs ?... or does this sort of 'clean
doc'  not exist ?
>
>   FYI: My environment: Tomcat 5.5.9, Sybase, Windows .
>   Many thanks!

--
Len

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Absolute Guide for config of JDBC Connection Pool ?

Giorgio Clavelli
In reply to this post by Len Popp
Great stuff Len!!!
Very much appreciated

A lost new java programmer
:)

On 1/20/06, Len Popp <[hidden email]> wrote:

>
> I don't know if there's a complete top-to-bottom guide, but here's
> what I know from setting up connection pooling under 5.5.12:
>
> 1. The JDBC driver JAR must go in the common/lib directory (because
> for connection pooling it needs to be accessible to both Tomcat and
> the web app).
>
> 2. DBCP is built into Tomcat so you don't need to install a JAR for that.
>
> 3. The <Resource> tag goes inside the <Context> tag for the web app,
> wherever it is (server.xml, webapps/<app>/META-INF/context.xml or
> conf/Catalina/localhost/<app>.xml)
> Note that the syntax for <Resource> has changed from earlier versions
> – see the Tomcat documentation. Here's a sample:
>
> <Resource name="jdbc/???"
>     type="javax.sql.DataSource"
>     auth="Container"
>     driverClassName="com.mysql.jdbc.Driver"
>     url="jdbc:mysql://localhost:3306/???"
>     username="???"
>     password="???"
>     maxIdle="15"
>     maxActive="50"
>     maxWait="10000"
>     factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
>     removeAbandoned="true"
>     removeAbandonedTimeout="60"
>     logAbandoned="true"/>
>
> The "???" bits are installation-dependent. Some of the parameters will
> be different for Sybase (driverClassName and url for sure).
>
> 4. Yes, it is supposed to say "... .dbcp.dbcp ..." in the factory= line.
>
> 5. The code to get a DB connection is:
>     InitialContext initCtx = new InitialContext();
>     DataSource ds = (DataSource) initCtx.lookup("java:comp/env/jdbc/???");
>     Connection conn = ds.getConnection();
> Make sure that "jdbc/???" is the same here as in the <Resource> tag.
>
> 6. Always close the connection when you're done with it. Use a
> "finally" block to make sure.
>
> 7. If you're trying to decide where to put the <Context> declaration,
> the choices are:
> - server.xml – Don't put it here. We're told it's bad.
> - webapps/<app>/META-INF/context.xml – If you put it here, it will be
> bundled up in the app's WAR file. That makes it easier to install, but
> harder to configure if every installation has different details for
> the database <Resource> tag.
> - conf/Catalina/localhost/<app>.xml – If you put it here, it's easier
> to edit the <Resource> tag, but it's an extra file to be installed in
> addition to the WAR.
>
> Hope this helps. At least it's shorter than
>
> http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
> .
> :-)
>
> On 1/19/06, g m <[hidden email]> wrote:
> > There seems to be 'truckloads' of information on just as many forums on
> how best to setup a JDBC connection pool, varying from which file to put
> what entries (server.xml, context.xml, web.xml) etc....
> >
> >   It looks like the same questions be asked in a slightly different
> fashion and for different environments.
> >
> >   Does anyone happen to know where there is a definative guide on how to
> do this and what jar files one needs ?... or does this sort of 'clean
> doc'  not exist ?
> >
> >   FYI: My environment: Tomcat 5.5.9, Sybase, Windows .
> >   Many thanks!
>
> --
> Len
>
Reply | Threaded
Open this post in threaded view
|

RE: Absolute Guide for config of JDBC Connection Pool ?

jack-24
In reply to this post by Bernie Durfee
Agreed!   Simple no-nonsense description - I shall give it a 'whirl' .....
   
  Thanks Len - your on my Xmas list ;-)

"Durfee, Bernard" <[hidden email]> wrote:
  Excellent! That is the exact documentation that should be on the Tomcat
site. It would also be nice to see a quick description of how Tomcat
processes the sections, what exactly it does with the
attributes, so that other drivers and pools can be configured.

There are also other parameters that DBCP accepts...

http://jakarta.apache.org/commons/dbcp/configuration.html

Bernie Durfee



> -----Original Message-----
> From: Len Popp [mailto:[hidden email]]
> Sent: Thursday, January 19, 2006 12:58 PM
> To: Tomcat Users List
> Subject: Re: Absolute Guide for config of JDBC Connection Pool ?
>
>
> I don't know if there's a complete top-to-bottom guide, but here's
> what I know from setting up connection pooling under 5.5.12:
>
> 1. The JDBC driver JAR must go in the common/lib directory (because
> for connection pooling it needs to be accessible to both Tomcat and
> the web app).
>
> 2. DBCP is built into Tomcat so you don't need to install a
> JAR for that.
>
> 3. The tag goes inside the tag for the web app,
> wherever it is (server.xml, webapps//META-INF/context.xml or
> conf/Catalina/localhost/.xml)
> Note that the syntax for has changed from earlier versions
> - see the Tomcat documentation. Here's a sample:
>
> > type="javax.sql.DataSource"
> auth="Container"
> driverClassName="com.mysql.jdbc.Driver"
> url="jdbc:mysql://localhost:3306/???"
> username="???"
> password="???"
> maxIdle="15"
> maxActive="50"
> maxWait="10000"
> factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
> removeAbandoned="true"
> removeAbandonedTimeout="60"
> logAbandoned="true"/>
>
> The "???" bits are installation-dependent. Some of the parameters will
> be different for Sybase (driverClassName and url for sure).
>
> 4. Yes, it is supposed to say "... .dbcp.dbcp ..." in the
> factory= line.
>
> 5. The code to get a DB connection is:
> InitialContext initCtx = new InitialContext();
> DataSource ds = (DataSource)
> initCtx.lookup("java:comp/env/jdbc/???");
> Connection conn = ds.getConnection();
> Make sure that "jdbc/???" is the same here as in the tag.
>
> 6. Always close the connection when you're done with it. Use a
> "finally" block to make sure.
>
> 7. If you're trying to decide where to put the declaration,
> the choices are:
> - server.xml - Don't put it here. We're told it's bad.
> - webapps//META-INF/context.xml - If you put it here, it will be
> bundled up in the app's WAR file. That makes it easier to install, but
> harder to configure if every installation has different details for
> the database tag.
> - conf/Catalina/localhost/.xml - If you put it here, it's easier
> to edit the tag, but it's an extra file to be installed in
> addition to the WAR.
>
> Hope this helps. At least it's shorter than
> http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-exampl
es-howto.html.
:-)

On 1/19/06, g m wrote:
> There seems to be 'truckloads' of information on just as many forums
on how best to setup a JDBC connection pool, varying from which file to
put what entries (server.xml, context.xml, web.xml) etc....
>
> It looks like the same questions be asked in a slightly different
fashion and for different environments.
>
> Does anyone happen to know where there is a definative guide on how
to do this and what jar files one needs ?... or does this sort of 'clean
doc' not exist ?
>
> FYI: My environment: Tomcat 5.5.9, Sybase, Windows .
> Many thanks!

--
Len

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

 


               
---------------------------------
 Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews, & more on new and used cars.
Reply | Threaded
Open this post in threaded view
|

RE: Absolute Guide for config of JDBC Connection Pool ?

jack-24
Ok, I have tried it....it fails ..or maybe I am helping it fail?
   
  Been fighting with it all morning......I followed your email and the doc...here are my entries/values..any opinions on what else to try?
   
   
  1. Resource entry values
 
 <Context path="/DBS3" docBase="DBS3" reloadable="true"  >
   <Resource name="jdbc/deebee"  
  type="javax.sql.DataSource"
  auth="Container"
  driverClassName="com.sybase.jdbc3.jdbc.SybDriver"  
  url="jdbc:sybase:Tds:10.xx.xxx.xx:5001"
  username="xxxxx"
  password="xxxx"
  maxIdle="15"
  maxActive="50"
  maxWait="10000"
  factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
  removeAbandoned="true"
  removeAbandonedTimeout="60"
  logAbandoned="true"/>
    </Context>
 
2. web.xml entry
   
   <description>Sybase Connection Resource</description>
 <resource-ref>
  <res-ref-name>jdbc/deebee</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
 </resource-ref>
 
3. Java code - error checking left out...
   
          Context ctx = new InitialContext();
        DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/deebee");
        Connection dbconn = ds.getConnection() ;
 
5. Put resource entry in file conf/Catalina/localhost/DBS3.xml with following error:
 
     "WARNING: A docBase C:\Program Files\Apache Software Foundation\
             Tomcat 5.5\webapps\DBS3 inside the host appBase has been
             specified, and will be ignored"
   
  6. Put resource entry in server.xml with error.
   
      SQLState: null
    Code: 0
    Message: Cannot create JDBC driver of class '' for connect URL 'null'
 
 
7. Put it in webapps/DBS3/META-INF/context.xml with error.
   
      SQLState: null
    Code: 0
    Message: Cannot create JDBC driver of class '' for connect URL 'null'
   
   
  any suggestions gladly taken ....
Thanks!
   
   
   
   
 

g m <[hidden email]> wrote:
  Agreed! Simple no-nonsense description - I shall give it a 'whirl' .....

Thanks Len - your on my Xmas list ;-)

"Durfee, Bernard" wrote:
Excellent! That is the exact documentation that should be on the Tomcat
site. It would also be nice to see a quick description of how Tomcat
processes the sections, what exactly it does with the
attributes, so that other drivers and pools can be configured.

There are also other parameters that DBCP accepts...

http://jakarta.apache.org/commons/dbcp/configuration.html

Bernie Durfee



> -----Original Message-----
> From: Len Popp [mailto:[hidden email]]
> Sent: Thursday, January 19, 2006 12:58 PM
> To: Tomcat Users List
> Subject: Re: Absolute Guide for config of JDBC Connection Pool ?
>
>
> I don't know if there's a complete top-to-bottom guide, but here's
> what I know from setting up connection pooling under 5.5.12:
>
> 1. The JDBC driver JAR must go in the common/lib directory (because
> for connection pooling it needs to be accessible to both Tomcat and
> the web app).
>
> 2. DBCP is built into Tomcat so you don't need to install a
> JAR for that.
>
> 3. The tag goes inside the tag for the web app,
> wherever it is (server.xml, webapps//META-INF/context.xml or
> conf/Catalina/localhost/.xml)
> Note that the syntax for has changed from earlier versions
> - see the Tomcat documentation. Here's a sample:
>
> > type="javax.sql.DataSource"
> auth="Container"
> driverClassName="com.mysql.jdbc.Driver"
> url="jdbc:mysql://localhost:3306/???"
> username="???"
> password="???"
> maxIdle="15"
> maxActive="50"
> maxWait="10000"
> factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
> removeAbandoned="true"
> removeAbandonedTimeout="60"
> logAbandoned="true"/>
>
> The "???" bits are installation-dependent. Some of the parameters will
> be different for Sybase (driverClassName and url for sure).
>
> 4. Yes, it is supposed to say "... .dbcp.dbcp ..." in the
> factory= line.
>
> 5. The code to get a DB connection is:
> InitialContext initCtx = new InitialContext();
> DataSource ds = (DataSource)
> initCtx.lookup("java:comp/env/jdbc/???");
> Connection conn = ds.getConnection();
> Make sure that "jdbc/???" is the same here as in the tag.
>
> 6. Always close the connection when you're done with it. Use a
> "finally" block to make sure.
>
> 7. If you're trying to decide where to put the declaration,
> the choices are:
> - server.xml - Don't put it here. We're told it's bad.
> - webapps//META-INF/context.xml - If you put it here, it will be
> bundled up in the app's WAR file. That makes it easier to install, but
> harder to configure if every installation has different details for
> the database tag.
> - conf/Catalina/localhost/.xml - If you put it here, it's easier
> to edit the tag, but it's an extra file to be installed in
> addition to the WAR.
>
> Hope this helps. At least it's shorter than
> http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-exampl
es-howto.html.
:-)

On 1/19/06, g m wrote:
> There seems to be 'truckloads' of information on just as many forums
on how best to setup a JDBC connection pool, varying from which file to
put what entries (server.xml, context.xml, web.xml) etc....
>
> It looks like the same questions be asked in a slightly different
fashion and for different environments.
>
> Does anyone happen to know where there is a definative guide on how
to do this and what jar files one needs ?... or does this sort of 'clean
doc' not exist ?
>
> FYI: My environment: Tomcat 5.5.9, Sybase, Windows .
> Many thanks!

--
Len

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]





---------------------------------
Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews, & more on new and used cars.  


               
---------------------------------
Yahoo! Photos – Showcase holiday pictures in hardcover
 Photo Books. You design it and we’ll bind it!
Reply | Threaded
Open this post in threaded view
|

RE: Absolute Guide for config of JDBC Connection Pool ?

Bernie Durfee
In reply to this post by jack-24
Since the <context> element is outside of the server.xml file, you don't
need the 'path' attribute. From
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

"The value of this field [path] must not be set except when statically
defining a Context in server.xml, as it will be inferred from the
filenames used for either the .xml context file or the docBase."

Also, the docBase is only needed when your web application is outside of
the 'webapps' directory.

"You may specify an absolute pathname for this directory or WAR file, or
a pathname that is relative to the appBase directory of the owning
Host."

But those are probably unrelated to the JDBC issue. Make sure that your
JDBC driver is in the common/lib directory with the DBCP jar files.
Since the Tomcat DBCP library will be instantiating the driver, it needs
to be able to find the driver in the same classloader. See
http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html

Now as far as the message itself, most would scoff at the idea that a
non-useful error message is a critical bug, but your frustration
demonstrates how poor error messages are just as damaging as "real"
bugs!

SQLState: null
Code: 0
Message: Cannot create JDBC driver of class '' for connect URL 'null'

How useful! DBCP is not much better, their error logging is nearly
non-existent.

Bernie Durfee



> -----Original Message-----
> From: g m [mailto:[hidden email]]
> Sent: Friday, January 20, 2006 6:22 AM
> To: Tomcat Users List
> Subject: RE: Absolute Guide for config of JDBC Connection Pool ?
>
>
> Ok, I have tried it....it fails ..or maybe I am helping it fail?
>    
>   Been fighting with it all morning......I followed your
> email and the doc...here are my entries/values..any opinions
> on what else to try?
>    
>    
>   1. Resource entry values
>  
>  <Context path="/DBS3" docBase="DBS3" reloadable="true"  >
>    <Resource name="jdbc/deebee"  
>   type="javax.sql.DataSource"
>   auth="Container"
>   driverClassName="com.sybase.jdbc3.jdbc.SybDriver"  
>   url="jdbc:sybase:Tds:10.xx.xxx.xx:5001"
>   username="xxxxx"
>   password="xxxx"
>   maxIdle="15"
>   maxActive="50"
>   maxWait="10000"
>   factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
>   removeAbandoned="true"
>   removeAbandonedTimeout="60"
>   logAbandoned="true"/>
>     </Context>
>  
> 2. web.xml entry
>    
>    <description>Sybase Connection Resource</description>
>  <resource-ref>
>   <res-ref-name>jdbc/deebee</res-ref-name>
>   <res-type>javax.sql.DataSource</res-type>
>   <res-auth>Container</res-auth>
>  </resource-ref>
>  
> 3. Java code - error checking left out...
>    
>           Context ctx = new InitialContext();
>         DataSource ds = (DataSource)
> ctx.lookup("java:comp/env/jdbc/deebee");
>         Connection dbconn = ds.getConnection() ;
>  
> 5. Put resource entry in file
> conf/Catalina/localhost/DBS3.xml with following error:
>  
>      "WARNING: A docBase C:\Program Files\Apache Software Foundation\
>              Tomcat 5.5\webapps\DBS3 inside the host appBase has been
>              specified, and will be ignored"
>    
>   6. Put resource entry in server.xml with error.
>    
>       SQLState: null
>     Code: 0
>     Message: Cannot create JDBC driver of class '' for
> connect URL 'null'
>  
>  
> 7. Put it in webapps/DBS3/META-INF/context.xml with error.
>    
>       SQLState: null
>     Code: 0
>     Message: Cannot create JDBC driver of class '' for
> connect URL 'null'
>    
>    
>   any suggestions gladly taken ....
> Thanks!
>    
>    
>    
>    
>  
>
> g m <[hidden email]> wrote:
>   Agreed! Simple no-nonsense description - I shall give it a
> 'whirl' .....
>
> Thanks Len - your on my Xmas list ;-)
>
> "Durfee, Bernard" wrote:
> Excellent! That is the exact documentation that should be on
> the Tomcat
> site. It would also be nice to see a quick description of how Tomcat
> processes the sections, what exactly it does with the
> attributes, so that other drivers and pools can be configured.
>
> There are also other parameters that DBCP accepts...
>
> http://jakarta.apache.org/commons/dbcp/configuration.html
>
> Bernie Durfee
>
>
>
> > -----Original Message-----
> > From: Len Popp [mailto:[hidden email]]
> > Sent: Thursday, January 19, 2006 12:58 PM
> > To: Tomcat Users List
> > Subject: Re: Absolute Guide for config of JDBC Connection Pool ?
> >
> >
> > I don't know if there's a complete top-to-bottom guide, but here's
> > what I know from setting up connection pooling under 5.5.12:
> >
> > 1. The JDBC driver JAR must go in the common/lib directory (because
> > for connection pooling it needs to be accessible to both Tomcat and
> > the web app).
> >
> > 2. DBCP is built into Tomcat so you don't need to install a
> > JAR for that.
> >
> > 3. The tag goes inside the tag for the web app,
> > wherever it is (server.xml, webapps//META-INF/context.xml or
> > conf/Catalina/localhost/.xml)
> > Note that the syntax for has changed from earlier versions
> > - see the Tomcat documentation. Here's a sample:
> >
> > > type="javax.sql.DataSource"
> > auth="Container"
> > driverClassName="com.mysql.jdbc.Driver"
> > url="jdbc:mysql://localhost:3306/???"
> > username="???"
> > password="???"
> > maxIdle="15"
> > maxActive="50"
> > maxWait="10000"
> > factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
> > removeAbandoned="true"
> > removeAbandonedTimeout="60"
> > logAbandoned="true"/>
> >
> > The "???" bits are installation-dependent. Some of the
> parameters will
> > be different for Sybase (driverClassName and url for sure).
> >
> > 4. Yes, it is supposed to say "... .dbcp.dbcp ..." in the
> > factory= line.
> >
> > 5. The code to get a DB connection is:
> > InitialContext initCtx = new InitialContext();
> > DataSource ds = (DataSource)
> > initCtx.lookup("java:comp/env/jdbc/???");
> > Connection conn = ds.getConnection();
> > Make sure that "jdbc/???" is the same here as in the tag.
> >
> > 6. Always close the connection when you're done with it. Use a
> > "finally" block to make sure.
> >
> > 7. If you're trying to decide where to put the declaration,
> > the choices are:
> > - server.xml - Don't put it here. We're told it's bad.
> > - webapps//META-INF/context.xml - If you put it here, it will be
> > bundled up in the app's WAR file. That makes it easier to
> install, but
> > harder to configure if every installation has different details for
> > the database tag.
> > - conf/Catalina/localhost/.xml - If you put it here, it's easier
> > to edit the tag, but it's an extra file to be installed in
> > addition to the WAR.
> >
> > Hope this helps. At least it's shorter than
> > http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-exampl
> es-howto.html.
> :-)
>
> On 1/19/06, g m wrote:
> > There seems to be 'truckloads' of information on just as many forums
> on how best to setup a JDBC connection pool, varying from
> which file to
> put what entries (server.xml, context.xml, web.xml) etc....
> >
> > It looks like the same questions be asked in a slightly different
> fashion and for different environments.
> >
> > Does anyone happen to know where there is a definative guide on how
> to do this and what jar files one needs ?... or does this
> sort of 'clean
> doc' not exist ?
> >
> > FYI: My environment: Tomcat 5.5.9, Sybase, Windows .
> > Many thanks!
>
> --
> Len
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
>
>
> ---------------------------------
> Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews,
> & more on new and used cars.  
>
>
>
> ---------------------------------
> Yahoo! Photos - Showcase holiday pictures in hardcover
>  Photo Books. You design it and we'll bind it!
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Absolute Guide for config of JDBC Connection Pool ?

jack-24
Hi Bernard,
   
  This problem is 'windows' (yes, spealt...B:A:D)..related.
   
  This application needs to run on a HP Unix box but the development is happening on a XP pc using Eclipse (don't ask...;-)) .  It actually works if I place the exact resource entry I posted in the "catalina/localhost/<appname>.xml" file - on Unix.
   
  I have the 'exact' same tomcat version running on the XP box. I went back to basics and found that not even a standard DB connection creation in the servlet works:
   
  Class.forName("com.sybase.jdbc3.jdbc.SybDriver");
Connection conn = DriverManager.getConnection( "jdbc:sybase:Tds:xx.xxx.xxx.xx:5001", "foobar", "badabing");

  Same code works on the unix box. Not sure why it be different. The XP box in question can talk to Sybase using the Sybase openclient - so I am guessing it is related to the JDBC/jar file on the PC?....
   
  Having said that, what you suggest below is interesting and I will address once I have "hello world" on XP working....
   
  Thanks for your help.
   
  Jack
 
"Durfee, Bernard" <[hidden email]> wrote:
  Since the element is outside of the server.xml file, you don't
need the 'path' attribute. From
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

"The value of this field [path] must not be set except when statically
defining a Context in server.xml, as it will be inferred from the
filenames used for either the .xml context file or the docBase."

Also, the docBase is only needed when your web application is outside of
the 'webapps' directory.

"You may specify an absolute pathname for this directory or WAR file, or
a pathname that is relative to the appBase directory of the owning
Host."

But those are probably unrelated to the JDBC issue. Make sure that your
JDBC driver is in the common/lib directory with the DBCP jar files.
Since the Tomcat DBCP library will be instantiating the driver, it needs
to be able to find the driver in the same classloader. See
http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html

Now as far as the message itself, most would scoff at the idea that a
non-useful error message is a critical bug, but your frustration
demonstrates how poor error messages are just as damaging as "real"
bugs!

SQLState: null
Code: 0
Message: Cannot create JDBC driver of class '' for connect URL 'null'

How useful! DBCP is not much better, their error logging is nearly
non-existent.

Bernie Durfee



> -----Original Message-----
> From: g m [mailto:[hidden email]]
> Sent: Friday, January 20, 2006 6:22 AM
> To: Tomcat Users List
> Subject: RE: Absolute Guide for config of JDBC Connection Pool ?
>
>
> Ok, I have tried it....it fails ..or maybe I am helping it fail?
>
> Been fighting with it all morning......I followed your
> email and the doc...here are my entries/values..any opinions
> on what else to try?
>
>
> 1. Resource entry values
>
>
> > type="javax.sql.DataSource"
> auth="Container"
> driverClassName="com.sybase.jdbc3.jdbc.SybDriver"
> url="jdbc:sybase:Tds:10.xx.xxx.xx:5001"
> username="xxxxx"
> password="xxxx"
> maxIdle="15"
> maxActive="50"
> maxWait="10000"
> factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
> removeAbandoned="true"
> removeAbandonedTimeout="60"
> logAbandoned="true"/>
>
>
> 2. web.xml entry
>
> Sybase Connection Resource
>
> jdbc/deebee
> javax.sql.DataSource
> Container
>
>
> 3. Java code - error checking left out...
>
> Context ctx = new InitialContext();
> DataSource ds = (DataSource)
> ctx.lookup("java:comp/env/jdbc/deebee");
> Connection dbconn = ds.getConnection() ;
>
> 5. Put resource entry in file
> conf/Catalina/localhost/DBS3.xml with following error:
>
> "WARNING: A docBase C:\Program Files\Apache Software Foundation\
> Tomcat 5.5\webapps\DBS3 inside the host appBase has been
> specified, and will be ignored"
>
> 6. Put resource entry in server.xml with error.
>
> SQLState: null
> Code: 0
> Message: Cannot create JDBC driver of class '' for
> connect URL 'null'
>
>
> 7. Put it in webapps/DBS3/META-INF/context.xml with error.
>
> SQLState: null
> Code: 0
> Message: Cannot create JDBC driver of class '' for
> connect URL 'null'
>
>
> any suggestions gladly taken ....
> Thanks!
>
>
>
>
>
>
> g m wrote:
> Agreed! Simple no-nonsense description - I shall give it a
> 'whirl' .....
>
> Thanks Len - your on my Xmas list ;-)
>
> "Durfee, Bernard" wrote:
> Excellent! That is the exact documentation that should be on
> the Tomcat
> site. It would also be nice to see a quick description of how Tomcat
> processes the sections, what exactly it does with the
> attributes, so that other drivers and pools can be configured.
>
> There are also other parameters that DBCP accepts...
>
> http://jakarta.apache.org/commons/dbcp/configuration.html
>
> Bernie Durfee
>
>
>
> > -----Original Message-----
> > From: Len Popp [mailto:[hidden email]]
> > Sent: Thursday, January 19, 2006 12:58 PM
> > To: Tomcat Users List
> > Subject: Re: Absolute Guide for config of JDBC Connection Pool ?
> >
> >
> > I don't know if there's a complete top-to-bottom guide, but here's
> > what I know from setting up connection pooling under 5.5.12:
> >
> > 1. The JDBC driver JAR must go in the common/lib directory (because
> > for connection pooling it needs to be accessible to both Tomcat and
> > the web app).
> >
> > 2. DBCP is built into Tomcat so you don't need to install a
> > JAR for that.
> >
> > 3. The tag goes inside the tag for the web app,
> > wherever it is (server.xml, webapps//META-INF/context.xml or
> > conf/Catalina/localhost/.xml)
> > Note that the syntax for has changed from earlier versions
> > - see the Tomcat documentation. Here's a sample:
> >
> > > type="javax.sql.DataSource"
> > auth="Container"
> > driverClassName="com.mysql.jdbc.Driver"
> > url="jdbc:mysql://localhost:3306/???"
> > username="???"
> > password="???"
> > maxIdle="15"
> > maxActive="50"
> > maxWait="10000"
> > factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
> > removeAbandoned="true"
> > removeAbandonedTimeout="60"
> > logAbandoned="true"/>
> >
> > The "???" bits are installation-dependent. Some of the
> parameters will
> > be different for Sybase (driverClassName and url for sure).
> >
> > 4. Yes, it is supposed to say "... .dbcp.dbcp ..." in the
> > factory= line.
> >
> > 5. The code to get a DB connection is:
> > InitialContext initCtx = new InitialContext();
> > DataSource ds = (DataSource)
> > initCtx.lookup("java:comp/env/jdbc/???");
> > Connection conn = ds.getConnection();
> > Make sure that "jdbc/???" is the same here as in the tag.
> >
> > 6. Always close the connection when you're done with it. Use a
> > "finally" block to make sure.
> >
> > 7. If you're trying to decide where to put the declaration,
> > the choices are:
> > - server.xml - Don't put it here. We're told it's bad.
> > - webapps//META-INF/context.xml - If you put it here, it will be
> > bundled up in the app's WAR file. That makes it easier to
> install, but
> > harder to configure if every installation has different details for
> > the database tag.
> > - conf/Catalina/localhost/.xml - If you put it here, it's easier
> > to edit the tag, but it's an extra file to be installed in
> > addition to the WAR.
> >
> > Hope this helps. At least it's shorter than
> > http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-exampl
> es-howto.html.
> :-)
>
> On 1/19/06, g m wrote:
> > There seems to be 'truckloads' of information on just as many forums
> on how best to setup a JDBC connection pool, varying from
> which file to
> put what entries (server.xml, context.xml, web.xml) etc....
> >
> > It looks like the same questions be asked in a slightly different
> fashion and for different environments.
> >
> > Does anyone happen to know where there is a definative guide on how
> to do this and what jar files one needs ?... or does this
> sort of 'clean
> doc' not exist ?
> >
> > FYI: My environment: Tomcat 5.5.9, Sybase, Windows .
> > Many thanks!
>
> --
> Len
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
>
>
> ---------------------------------
> Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews,
> & more on new and used cars.
>
>
>
> ---------------------------------
> Yahoo! Photos - Showcase holiday pictures in hardcover
> Photo Books. You design it and we'll bind it!
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

 


               
---------------------------------
 
 What are the most popular cars?  Find out at Yahoo! Autos
Reply | Threaded
Open this post in threaded view
|

Re: Absolute Guide for config of JDBC Connection Pool ?

Hassan Schroeder
g m wrote:

>   This problem is 'windows' (yes, spealt...B:A:D)..related.

probably. :-)

>   Same code works on the unix box. Not sure why it be different.

>>"WARNING: A docBase C:\Program Files\Apache Software Foundation\
>>Tomcat 5.5\webapps\DBS3 inside the host appBase ...

Many people have reported problems on Windows boxes with Tomcat and
Java installed in directories with spaces in the names; you might
reinstall using e.g. `C:\java` and `C:`tomcat_5.5` or whatever...

>   Having said that, what you suggest below is interesting and I
> will address once I have "hello world" on XP working....

"I'll fix the broken configuration after I have it running"? Maybe
not the ideal approach. :-)

FWIW!
--
Hassan Schroeder ----------------------------- [hidden email]
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                          dream.  code.



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Absolute Guide for config of JDBC Connection Pool ?

jack-24

    > Having said that, what you suggest below is interesting and I
> will address once I have "hello world" on XP working....

"I'll fix the broken configuration after I have it running"? Maybe
not the ideal approach. :-)
   
  Configuration is not broken..as I  said it is running on HP...but thanks for the suggestion ;-)


               
---------------------------------
Yahoo! Photos
 Ring in the New Year with Photo Calendars. Add photos, events, holidays, whatever.
Reply | Threaded
Open this post in threaded view
|

Re: Absolute Guide for config of JDBC Connection Pool ?

jack-24
In reply to this post by Hassan Schroeder
I found the reason it was failing (but not yet the cure..), just in case others might hit this....
   
  When tomcat was started (through Eclipse), it was running the security manager (-Djava.security.manager -Djava.security.policy="C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\catalina.policy"), which was throwing the exception.

   I guess I either need to set the proper security level (need to learn about this) in the cataline.policy file, or, maybe remove this line - what I did to confirm it.
   
  Not sure if this line is added automatically by the eclipse plugin that I am using for tomcat (sysdemo), but at least I know now where to start addressing this.
   
  The connection pool also works now.
   
  Thanks all for your help !!!!
   
 
Hassan Schroeder <[hidden email]> wrote:
  g m wrote:

> This problem is 'windows' (yes, spealt...B:A:D)..related.

probably. :-)

> Same code works on the unix box. Not sure why it be different.

>>"WARNING: A docBase C:\Program Files\Apache Software Foundation\
>>Tomcat 5.5\webapps\DBS3 inside the host appBase ...

Many people have reported problems on Windows boxes with Tomcat and
Java installed in directories with spaces in the names; you might
reinstall using e.g. `C:\java` and `C:`tomcat_5.5` or whatever...

> Having said that, what you suggest below is interesting and I
> will address once I have "hello world" on XP working....

"I'll fix the broken configuration after I have it running"? Maybe
not the ideal approach. :-)

FWIW!
--
Hassan Schroeder ----------------------------- [hidden email]
Webtuitive Design === (+1) 408-938-0567 === http://webtuitive.com

dream. code.



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

 


               
---------------------------------
Yahoo! Photos
 Ring in the New Year with Photo Calendars. Add photos, events, holidays, whatever.