Skip site navigation (1) Skip section navigation (2)

Re: Tomcat JNDI configuration

From: Tom Arthurs <tarthurs(at)jobflash(dot)com>
To: Wojciech Michalik <wojtekmichalik(at)softtellco(dot)com(dot)pl>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Tomcat JNDI configuration
Date: 2005-10-17 04:54:40
Message-ID: 43532E90.1060304@jobflash.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
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
>
>
>  
>

In response to

pgsql-jdbc by date

Next:From: Stefano B.Date: 2005-10-17 11:11:21
Subject: could not connect to the server error: jdbc problem?
Previous:From: Wojciech MichalikDate: 2005-10-16 19:30:54
Subject: Tomcat JNDI configuration

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group