Re: a little disillusioned

Поиск
Список
Период
Сортировка
От David Wilbur
Тема Re: a little disillusioned
Дата
Msg-id AC13FEDE-506C-11D8-AC16-0003931D9176@cybermesa.com
обсуждение исходный текст
Ответ на a little disillusioned  ("Frequency UnKnown" <captainmofopants@hotmail.com>)
Ответы Re: a little disillusioned
Re: a little disillusioned
Список pgsql-jdbc
<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>5555,1A1A,8B8B</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>
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 по дате отправления:

Предыдущее
От: poonam talreja
Дата:
Сообщение: suitable driver not found
Следующее
От: "Thomas Hallgren"
Дата:
Сообщение: Pl/Java 1.0.0.b now avaiable on Linux 386 and Cygwin