473,324 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 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 5386

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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.