Re: a little disillusioned

From: David Wilbur <wildboar(at)cybermesa(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: a little disillusioned
Date: 2004-01-27 19:07:05
Message-ID: FF63F5B4-50FB-11D8-9A8D-0003931D9176@cybermesa.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


this may end up being a double post... my apologies if it is. i wasn't
registered and it stalled the post.

just wanted to mention that the person that was having tomcat issues is
not alone here. unfortunately the docs as far as tomcat and postgres
boils down to some major hand waving re the two. each relying on the
other to work things out for the other. mysql getting the best
treatment from the tomcat people.

the os that i am running this on is:

mac os 10.3.2,

java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-99)
Java HotSpot(TM) Client VM (build 1.4.1_01-27, mixed mode)

tomcat was compiled from jakarta-tomcat-5.0.16-src.tar.gz where it
pulls all the files off the jakarta site.

postgresql 7.4.1

the following is a really trimmed down version of code from the tomcat
examples re jdbc connection pools:

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/postgres");
try {
Connection conn = ds.getConnection();
if(conn != null) {
foo = "Got Connection "+conn.toString();
Statement stmt = conn.createStatement();
ResultSet rst = stmt.executeQuery( "select id, foo, bar
from testdata" );
if(rst.next()) {
foo=rst.getString(2);
bar=rst.getInt(3);
}
conn.close();
} catch (SQLException e) {
foo = "SQLException: " + e;
}

results in a index.jsp showing this for foo...

SQLException: org.apache.commons.dbcp.SQLNestedException: Cannot load
JDBC driver class 'org.postgres.Driver', cause: org.postgres.Driver

when i go into the administration utility i find a definition for the
data source where the web app is defined under

"/Tomcat Server/Catalina/localhost/DBTest/Data Sources"

JNDI Name JDBC Driver Class
jdbc/postgres   org.postgres.Driver

delving into that i see this:

JNDI Name: jdbc/postgres
Data Source URL: jdbc:postgresql://127.0.0.1:5432/test
JDBC Driver Class: org.postgres.Driver
User Name: jakarta
Password: "the correct password"
Max. Active Connections: 20
Max. Idle Connections: 10
Max. Wait for Connection: 10000
Validation Query:

i modified the basic.java file that comes with the postgres jdbc driver
and ran it using the connection string above

jdbc:postgresql://127.0.0.1:5432/test

and that works fine using the same jar file that tomcat is using.

there is only one jar file in the tomcat directorys and it is located
at:

find $CATALINA_HOME -name "postgresql.jar"
/usr/local/jakarta/tomcat/common/lib/postgresql.jar

my class path has only ant and java home on it and i have checked to
see if the jar is there.

what i think would be really awesome is if one of you that have this
working could look at the tomcat "documentation" for setting up
postgres and tomcat and maybe helping them and us by maybe making it
more intelligible... cause it is a mess as it is now. in fact if
someone helps me work this out and they don't want to do it i will...
see:

http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-
examples-howto.html

maybe even adding the same advice to the postgres jdbc examples so that
we would have a starting point that we knew was working for someone...
this is a nice starting point, but... it might be nice to add in
something along the line of how to set up a java web server to use
postgres.

http://www.postgresql.org/docs/current/static/jdbc-datasource.html

i am suspecting that maybe is one of the xml files... either
$CATALINA_HOME/conf/server.xml or the apps WEB-INF/web.xml... but i
really don't know for sure what i might have wrong there. in the mean
time i guess i will try the mysql setup the tomcat people define to see
if that works... since i have to do that too.

thanks in advance,
dave

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2004-01-27 19:22:50 Re: jdbc connection string
Previous Message Peter Eisentraut 2004-01-27 18:50:04 Re: Patch to readd documentation