pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Arthurs <tarthurs@jobflash.com>
To: Wojciech Michalik <wojtekmichalik@softtellco.com.pl>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Tomcat JNDI configuration
Date: Sun, 16 Oct 2005 21:54:40 -0700
Message-ID: <43532E90.1060304@jobflash.com> (raw)
In-Reply-To: <1129491053.6734.14.camel@localhost.localdomain>
References: <1129491053.6734.14.camel@localhost.localdomain>

your URL is wong.
change

<parameter>
<name>url</name>
<value>jdbc:postgresql:prac_samp_jsp://localhost:5432/prac_samp_jsp</value>
</parameter>
<parameter>

to:
<parameter>
<name>url</name>
<value>jdbc:postgresql//localhost:5432/prac_samp_jsp</value>
</parameter>
<parameter>

-- assuming that "prac_samp_jsp" is your data base name.

change

Wojciech Michalik wrote:

>I am using Tomcat (5.5.9|| 5.5.7) and 7.4 database version. In my
>application I am trying to create DBCP. Still getting this error:
>javax.servlet.ServletException: Unable to get connection, DataSource
>invalid: "java.sql.SQLException: No suitable driver
>
>Newest driver is in $TOMCAT_HOME/common/libs/
>When I try to use the database through normal connection everything
>works fine:
><sql:setDataSource var="my_data_source" driver="org.postgresql.Driver"
>url="jdbc:postgresql://localhost:5432/prac_samp_jsp" user="pingwin"
>password="pingwinek_-_"/>
><sql:query var="empList" scope="request" dataSource="${my_data_source}" 
>  
>
>  SELECT * FROM Employee 
>    WHERE FirstName LIKE ?
>      AND LastName LIKE ?
>      AND Dept LIKE ?
>    ORDER BY LastName
>  <sql:param value="%${param.firstName}%" />
>  <sql:param value="%${param.lastName}%" />
>  <sql:param value="%${param.dept}%" />
></sql:query>
>
>Piece of code from jsp page causing this error is:
><sql:query var="empList" scope="request">
>I do not specify any connection parameters  here.
>my aproprite web.xml piece:
><resource-ref>
>    <description>
>      JNDI DataSource for example database
>    </description>
>    <res-ref-name>jdbc/Sample_JSPBook</res-ref-name>
>    <res-type>javax.sql.DataSource</res-type>
>    <res-auth>Container</res-auth>
>    <res-sharing-scope>Sharable</res-sharing-scope>
>  </resource-ref>
>  <context-param>
>    <param-name>javax.servlet.jsp.jstl.sql.dataSource</param-name>
>    <param-value>jdbc/JSP_Book</param-value>
>  </context-param>
>
>In server.xml it looks like this:
><Resource name="jdbc/JSP_Book" auth="Container"
>          type="javax.sql.DataSource" />
> <ResourceParams name="jdbc/JSP_Book">
><parameter>
><name>factory</name>
><value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
></parameter>
><parameter>
><name>driverClassName</name>
><value>org.postgresql.Driver</value>
></parameter>
><parameter>
><name>url</name>
><value>jdbc:postgresql:prac_samp_jsp://localhost:5432/prac_samp_jsp</value>
></parameter>
><parameter>
><name>username</name> <!--Dont forget to change the realm
>username/password to-->
><value>myusername</value>
></parameter>
><parameter>
><name>password</name>
><value>mypassword</value>
></parameter>
><parameter>
><name>maxActive</name>
><value>25</value>
></parameter>
><!-- Maximum number of idle dB connections to retain in pool.
>Set to 0 for no limit.
>-->
><parameter>
><name>maxIdle</name>
><value>0</value>
></parameter>
><!-- Maximum time to wait for a dB connection to become available
>in ms, in this example 10 seconds. An Exception is thrown if
>this timeout is exceeded. Set to -1 to wait indefinitely.
>-->
><parameter>
><name>maxWait</name>
><value>-1</value>
></parameter>
><!-- To configure a DBCP DataSource so that abandoned dB connections are
>removed and
>recycled add the following paramater to the ResourceParams configuration
>for your DBCP
>DataSource Resource: -->
><parameter>
><name>removeAbandoned</name>
><value>true</value>
></parameter>
><!--Use the removeAbandonedTimeout parameter to set the number of
>seconds a dB connection has been idle before it is considered abandoned.
>-->
><parameter>
><name>removeAbandonedTimeout</name>
><value>600</value> <!--Wait 3 hour before statuating a connection is
>abandoned-->
></parameter>
>
><!-- The logAbandoned parameter can be set to true if you want DBCP to
>log a stack trace
>of the code which abandoned the dB connection resources. -->
>
>       <parameter>
>           <name>logAbandoned</name>
>           <value>true</value>
>       </parameter>
>
>
>
></ResourceParams>
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: don't forget to increase your free space map settings
>
>
>  
>

view thread (2+ messages)

Message-ID: <43532E90.1060304@jobflash.com>
Permalink:  ../43532E90.1060304@jobflash.com/
Also on:    postgresql.org/message-id/43532E90.1060304@jobflash.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: tarthurs@jobflash.com, wojtekmichalik@softtellco.com.pl
  Subject: Re: Tomcat JNDI configuration
  In-Reply-To: <43532E90.1060304@jobflash.com>
  References: <1129491053.6734.14.camel@localhost.localdomain> <43532E90.1060304@jobflash.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox