Our setup is like this, with the validation query in the ResourceParams

In server.xml 


<Server ..................>
<GlobalNamingResources>
    <Resource auth="Container" description="User database that can be
updated and saved" name="UserDatabase" scope="Shareable"
type="org.apache.catalina.UserDatabase"/>
   
<Resource name="postgres" scope="Shareable"
type="javax.sql.DataSource"/>
    
    <ResourceParams name="postgres">
      <parameter>
        <name>url</name>
        <value>jdbc:postgresql://serverip:port/databasename</value>
      </parameter>
      <parameter>
        <name>validationQuery</name>
        <value>select 1;</value>
      </parameter>
      <parameter>
        <name>maxIdle</name>
        <value>20</value>
      </parameter>
      <parameter>
        <name>maxActive</name>
        <value>40</value>
      </parameter>
      <parameter>
        <name>driverClassName</name>
        <value>org.postgresql.Driver</value>
      </parameter>
      <parameter>
        <name>maxWait</name>
        <value>50000</value>
      </parameter>
      <parameter>
        <name>username</name>
        <value>foo</value>
      </parameter>
      <parameter>
        <name>factory</name>
        <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
      </parameter>
      <parameter>
        <name>password</name>
        <value>bar</value>
      </parameter>
    </ResourceParams>
  </GlobalNamingResources>

and then in the context where we want to link to the database we have
<Context ................>
  <ResourceLink global="postgres" name="jdbc/postgres"
type="javax.sql.DataSource"/>

</Context>

Chris Catton
BioImage Database Development Manager
Department of Zoology
University of Oxford
OX1 3PS
�
Tel: +44 (0) 1865 281993
email: [EMAIL PROTECTED]
web site: www.bioimage.org


> -----Original Message-----
> From: awc [mailto:[EMAIL PROTECTED]]
> Sent: 21 February 2003 14:28
> To: Tomcat Users List
> Subject: Re: setting up jndi jdbc tomcat and postgres
> 
> Hi Chris,
> 
> where does this validationQuery goes?? on every connect??
> 
> Thanks
> 
> .anil
> 
> Chris Catton wrote:
> 
> > The tomcat documentation on jndi and datasources
> >
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples
> > -howto.html asks for  feedback on setup with postgres.  We finally
got
> > it working  using java 1.4, tomcat 4.1.18 on linux, postgres 7.2.1
on
> > linux with pg73jdbc2ee.jar.  The instructions miss one crucial thing
-
> > on our system we were getting a datasource created, but on trying to
get
> > a connection from the datasource the system seemed to hang.  A look
at
> > the postgres log showed repeated attempts to connect.  Problem
> > eventually solved by putting 'select 1;' in the validationQuery
> >
> > Seems the postgres driver wants the database to confirm the
connection
> > is valid before handing it  back ..
> >
> > Hope this saves someone else some headscratching - pls stick it in
the
> > docs!
> >
> > C
> >
> >
> >
> > Chris Catton
> > BioImage Database Development Manager
> > Department of Zoology
> > University of Oxford
> > OX1 3PS
> >
> > Tel: +44 (0) 1865 281993
> > email: [EMAIL PROTECTED]
> > web site: www.bioimage.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to