472,782 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,782 software developers and data experts.

JNDI DataSource with PostgreSQL and Tomcat

Hello group,

I have some questions concerning configuring and using a JNDI DataSource
with PostgreSQL and Apache Tomcat. Currently, I belive I have
successfully configured a "basic" DataSource. Currently, my configuration
which resides in a context.xml file is as follows:

<Context className="org.apache.catalina.core.StandardContex t"
backgroundProcessorDelay="-1"
cachingAllowed="true"

charsetMapperClass="org.apache.catalina.util.Chars etMapper"

configFile="/usr/local/jwsdp-1.3/conf/Catalina/localhost/test.xml"
cookies="true"
crossContext="false"
debug="0"
displayName="test"
docBase="/usr/local/jwsdp-1.3/webapps/test"
domain="Catalina"
engineName="Catalina"
j2EEApplication="none"
j2EEServer="none"
lazy="true"
managerChecksFrequency="6"
path="/test"
privileged="false"
reloadable="true"
startupTime="8"
swallowOutput="false"
tldScanTime="0"
useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWra pper">

<Resource name="jdbc/test" scope="Shareable"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/test">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFact ory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.postgresql.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:postgresql://myIP/test</value>
</parameter>
<parameter>
<name>username</name>
<value>Whoopie</value>
</parameter>
<parameter>
<name>password</name>
<value>Doopie</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>20</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>5</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
<parameter>
<name>validationQuery</name>
<value>SELECT * FROM test</value>
</parameter>
</ResourceParams>
</Context>

Using the above configuration, my JSP pages can connect to PostgreSQL and
perform all required database operations.

But all is not right! I have the following issues:

1.) Connections are NEVER closed
Say I hit my JSP page which perform a query and display the results.
Using netstat I can see that one connection to PostgreSQL has been
established. But then, if I uninstall and reinstall my web app and hit my
JSP page again, then the output of "netstat -p -t" shows that a second
connection to PostgreSQL is established.
The first connection never goes away! If I continue to
uninstall/reinstall/hit JSP page, the connections continue to acrue and
never go away. The number of connections can even exceed the value of
"maxActive" defined in my context.xml file. What am I doing wrong?

2.) Idle connections aren't closed
As mentioned above, the connections which are opened by my web app are
kept around forever and never closed. In my context.xml file above, I've
defined the "removeAbandoned" parameter to true and have set the
"removeAbandonedTimeout" parameter to 20 seconds. But the connections are
never closed. Every time I run "netstat -p -t", there they are. :(

3.) Is my configuration correct for performing Pooling?
I "can" get "a" database connection using this configuration. But is this
adequate to perform connection pooling? How can I tell if/when connection
pooling is actually being performed correctly?

Any help would be greatly appreciated.

Thanks,
w.k.
Jul 19 '05 #1
0 5356

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: mdh | last post by:
I am trying to learn the basics of MVC applications using a Tomcat infrastructure. I'm starting by building a simple application with: * a login.jsp page for a basic login form with a action...
2
by: Jon Dellaria | last post by:
I have been using MySql as the database using JSP's and JavaBeans but recently I have wanted to start using the database connection pooling mechanism built into TomCat. I think I am having a...
1
by: Kent | last post by:
I'm running on Win2000 and JRE 1.4.1.... I've got a small client trying to do get an InitialContext() and talk to the local JBoss server running on same machine (different VM of course). When...
1
by: slurper | last post by:
i have problems understanding jndi. i'm this far: i deployed the sun application server and i'm working through the examples (Duke bookstore, ...). Sometimes i see code which does a lookup to a...
1
by: John Chambers | last post by:
Hi all, I'm relatively new to JNDI concepts and need some help. I am writing a web app that accepts a variable specifying a jndi pooled connection datasource as a url variable. This is a...
1
by: phil campaigne | last post by:
On Mon, 1 Mar 2004, phil campaigne wrote: >> Nigel J. Andrews wrote: >> > > >>> >On Mon, 1 Mar 2004, Phil Campaigne wrote: >>> > >>> >
10
dmjpro
by: dmjpro | last post by:
My context.xml... <Context path="/JNDITest"> <Resource name="jdbc/dataSource" auth="Container" type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"...
9
dmjpro
by: dmjpro | last post by:
I thought that when the connection gets closed then all resources get closed . I also included the ResultSet and Statement ;) . But if the Statement closed then only ResultSet closed. But now i got...
1
by: kokababu | last post by:
Hi I am developing a WebService using Java (JAX-RPC). According to the requirement, I have to create a Thread to insert data into Database. So I am opening a database connection in the...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.