Connection pooling question [message #44697] |
Fri, 17 September 2004 11:48  |
Eclipse User |
|
|
|
Originally posted by: shyun_chen.yahoo.com
Hi,
I am using Eclipse 3.0 & IBM's web tooling platform contribution.
Anyone knows how to setup database connection pooling from Eclipse using
Tomcat as web server to connect to MS SQL server ?
I setup my Tomcat environment, server.xml & web.xml files according to
Tomcat's "JNDI Datasource HOW-TO"
( http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasou rce-examples-howto.html)
but I am still getting the
"javax.naming.NameNotFoundException: Name jdbc is not bound in this
Context" error. Is there any trick that I need to do in Eclipse
environment?
My Eclipse version 3.0.0
My Tomcat version 5.0.19
Thanks,
Shyun Chen
|
|
|
|
|
Re: Connection pooling question [message #44861 is a reply to message #44776] |
Sat, 18 September 2004 09:40  |
Eclipse User |
|
|
|
Shyun Chen wrote:
> My web project name is TestWeb under Eclipse. Every time I
> stop&start/restart
> the Tomcat server from the Eclipse's Server view, a new version of the
> TestWeb.xml will be created in the TomcatHome\conf\Catalina\localhost
> directory
> with minimum content. (No ResourceLink information)
>
> My questions are:
> (1) Is this Eclipse's behavior or Tomcat's behavior?
This is eclipse behavior. Actually WTP's server tooling behavior.
> (2) Can I somehow setup the content of my TestWeb.xml file?
First of all I think tomcat server tooling should have better
documentation. Second, tomcat should have even better documentation
about JNDI resource management. If you google JNDI resource related
Tomcat problems you'll find thousands of results.
Anyway, your best bet is confuguring JNDI resources in server.xml. To my
understanding you can't configure your resource in META-INF/context.xml
or TomcatHome/conf/Catalina/localhost/<YourApp>.xml.
This way your resource will be available to all applications that refers
to the resource in web.xml.
In your server.xml, immediately after <Host...> tag place the following
DefaultContext declaration:
<DefaultContext>
<Resource auth="Container" name="jdbc/resource_name"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/resource_name">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value >
</parameter>
<parameter>
<name>url</name>
<value>your_url</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>your_driver</value>
</parameter>
<parameter>
<name>username</name>
<value>your_username</value>
</parameter>
<parameter>
<name>password</name>
<value>your_password</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>
</ResourceParams>
</DefaultContext>
And, in your application's web.xml file add the following before
</web-app> tag:
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/resource_name</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
HTH.
/tb.
|
|
|
Powered by
FUDForum. Page generated in 0.03606 seconds