Re: a little disillusioned - Mailing list pgsql-jdbc

From David Wilbur
Subject Re: a little disillusioned
Date
Msg-id 39A6B5CE-54E2-11D8-ADFD-0003931D9176@cybermesa.com
Whole thread Raw
In response to Re: a little disillusioned  (David Wilbur <wildboar@cybermesa.com>)
List pgsql-jdbc

this is weird... the list is saying that i sent this yesterday... but
i originally sent it as you can see on the 26th.  ie: this is a repeat
post that i didn't do.  it even thinks of it's self as being from
headers as sent  <bold><color><param>0000,0000,0000</param>Date:
</color></bold><color><param>0000,0000,0000</param>    </color>January
26, 2004 7:01:08 PM MST  even thou it was received yesterday (for the
2nd time)


anyone know how this happened?  in fact i wasn't able to read mail
since the original post so i couldn't have posted this yesterday. does
the list manager duplicate send from time to time?




btw the problem was that i was missing the "ql" in the driver
reference. /blush  ie:  i had: org.postgres.Driver when i should have
had  org.postgresql.Driver  it always seems to be simple things
overlooked.


thanks to Dave Cramer for all his useful comments and JariP too.


david



On Jan 26, 2004, at 7:01 PM, David Wilbur wrote:


<excerpt><fontfamily><param>Courier</param>

just wanted to mention that this person is not alone here.
unfortunately the docs as far as tomcat and postgres boils down to
some major hand waving.  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"


<color><param>0000,0000,0000</param>JNDI Name       JDBC Driver Class</color>

<color><param>5554,1A19,8B8A</param>jdbc/postgres</color>  
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 it is one of the xml files... either
<x-tad-bigger>$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.


thanks in advance,

dave

</x-tad-bigger></fontfamily></excerpt>
this is weird... the list is saying that i sent this yesterday... but i
originally sent it as you can see on the 26th.  ie: this is a repeat
post that i didn't do.  it even thinks of it's self as being from
headers as sent  Date:     January 26, 2004 7:01:08 PM MST  even thou it
was received yesterday (for the 2nd time)

anyone know how this happened?  in fact i wasn't able to read mail
since the original post so i couldn't have posted this yesterday. does
the list manager duplicate send from time to time?



btw the problem was that i was missing the "ql" in the driver
reference. /blush  ie:  i had: org.postgres.Driver when i should have
had  org.postgresql.Driver  it always seems to be simple things
overlooked.

thanks to Dave Cramer for all his useful comments and JariP too.

david


On Jan 26, 2004, at 7:01 PM, David Wilbur wrote:

>
> just wanted to mention that this person is not alone here.
> unfortunately the docs as far as tomcat and postgres boils down to
> some major hand waving.  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 it 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.
>
> thanks in advance,
> dave

pgsql-jdbc by date:

Previous
From: "Dave Page"
Date:
Subject: Re: FW: [webmaster] jdbc site: documentation links broken
Next
From: Dave Cramer
Date:
Subject: Re: FW: [webmaster] jdbc site: documentation links broken