Re: Tomcat 5.5.8 Postgresql 7.4.6 No suitable driver exception

2005-03-05 Thread Ole Ersoy
Thanks Doug!

For the rest of us, here are the steps I used to
resolve this, per Doug's info:

First I was missing some very important posgresql
configuration steps.

These can be found here:
http://www.fankhausers.com/postgresql/jdbc/

Summary:
- Needed to enable tcp/ip connection to the database
  located in var/lib/pgsql/data/postresql.conf
- Needed to allow access to the database (pg_hba.conf)

After this I left server.xml in its original state (as
it comes with tomcat) and put the application context
descriptor containing the connection pool in
$CATALINA_HOME/conf/Catalina/localhost

and . IT WORKS

Thanks again,
- Ole 

--- Parsons Technical Services
[EMAIL PROTECTED] wrote:

 Your update to the server.xml must be one of two
 way.
 
 Declare it in a context tag set or in a
 GlobalResource tag set.
 
 If done in a GlobalResource then a ResourceLink is
 also needed.
 
 If you don't declare your context in the server.xml,
 you can declare your 
 resource in your context tag that resides in your
 app. This will make it 
 available to your app only.
 
 I think there is a typo on the page. I believe that
 it must be declared 
 inside a context pair. The page text lead one to
 think it only has to be 
 inside the host tags.
 

http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html#Database%20Connection%20Pool%20(DBCP)%20Configurations
 
 Doug
 
 - Original Message - 
 From: Ole Ersoy [EMAIL PROTECTED]
 To: Tomcat Users List
 tomcat-user@jakarta.apache.org
 Sent: Friday, March 04, 2005 9:45 AM
 Subject: Re: Tomcat 5.5.8 Postgresql 7.4.6 No
 suitable driver exception
 
 
  Sorry - wrong wget lines - I meant to provide this
  statement:
  wget
 

http://jdbc.postgresql.org/download/pg74.215.jdbc2.jar
 
  I then untarred it in the common lib directory.  I
  tried both the type 2 and type 3 driver.
 
  Thanks,
  - Ole
  --- Ole Ersoy [EMAIL PROTECTED] wrote:
 
  David,
 
  I downloaded it and un-zipped it here:
 
   cd /usr/local/jakarta-tomcat-5.5.7/common/lib
  - wget
 

http://cvs.apache.org/builds/jakarta-taglibs/nightly/jakarta-taglibs-20050303.tar.gz
  - tar xzf jakarta-taglibs-20050303.tar.gz
 
  I've tried both type two and type 3 drivers,
 since
  the
  example was a bit vague on which driver is
 currently
  supported by DBCP.
 
  Thanks though,
  - Ole
  --- David Smith [EMAIL PROTECTED] wrote:
 
   One of the only things I don't see here -- and
  it's
   a big one -- no
   postgresql jdbc driver in common/lib.  Tomcat
   doesn't come with it by
   default.  You have to download the latest and
   install it before this
   will work.
  
   --David
  
   Ole Ersoy wrote:
  
   Hi everybody,
   
   I'm attempting to get the JNDI Datasource How
 To
   example for Postgresql to work.
   
   Here is the URL for the example:
  
 

http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
   
   After completing the listed steps the test.jsp
   error
   page reports:
   java.sql.SQLException: No suitable driver
   
   Here are all my configuration steps, including
  the
   files:
   - On Fedora Core 3 - adduser postgres
   - passwd postgres (set to postgres)
   - chown postgres /var/lib/pqsql/data
   - /usr/bin/initdb -D /var/lib/pgsql/data
   - /usr/bin/postmaster -D /var/lib/pgsql/data
   logfile
   21 
   - createdb test postgres
   - psql test
   create table testdata (id int not null primary
  key,
   foo varchar(25), bar int);
   insert into testdata values(1, 'hello',
 12345);
   - Update server.xml with this under the
 /Host
   tag:
   Resource name=jdbc/postgres
 auth=Container
 type=javax.sql.DataSource
   driverClassName=org.postgresql.Driver
   
   url=jdbc:postgresql://127.0.0.1:5432/mydb
 username=postgres
 password=postgres
   maxActive=20 maxIdle=10 maxWait=-1/
   /Context
cd /usr/local/jakarta-tomcat-5.5.7/common/lib
   - wget
  
 

http://cvs.apache.org/builds/jakarta-taglibs/nightly/jakarta-taglibs-20050303.tar.gz
   - tar xzf jakarta-taglibs-20050303.tar.gz
   - mkdir /var/www/webapps/dbtest
   - vi /var/www/webapps/dbtest/test.jsp (I put
 the
   example code here)
   Here it is just in case:
   
   
   %@ taglib
 uri=http://java.sun.com/jsp/jstl/sql;
   prefix=sql %
   %@ taglib
  uri=http://java.sun.com/jsp/jstl/core;
   prefix=c %
   
   sql:query var=rs dataSource=jdbc/TestDB
   select id, foo, bar from testdata
   /sql:query
   
   html
 head
   titleDB Test/title
 /head
 body
   
 h2Results/h2
   
   c:forEach var=row items=${rs.rows}
   Foo ${row.foo}br/
   Bar ${row.bar}br/
   /c:forEach
   
 /body
   /html
   
   - mkdir /var/www/webapps/dbtest/WEB-INF/
   - vi /var/www/webapps/dbtest/WEB-INF/web.xml
   
   I have the following in web.xml
   web-app
 xmlns=http://java.sun.com/xml/ns/j2ee;
   
  
 

xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
   
  
 
 xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
  
 http://java.sun.com/xml/ns/j2ee/web

Re: Tomcat 5.5.8 Postgresql 7.4.6 No suitable driver exception

2005-03-04 Thread David Smith
One of the only things I don't see here -- and it's a big one -- no 
postgresql jdbc driver in common/lib.  Tomcat doesn't come with it by 
default.  You have to download the latest and install it before this 
will work.

--David
Ole Ersoy wrote:
Hi everybody,
I'm attempting to get the JNDI Datasource How To
example for Postgresql to work.
Here is the URL for the example:
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
After completing the listed steps the test.jsp error
page reports:
java.sql.SQLException: No suitable driver
Here are all my configuration steps, including the
files:
- On Fedora Core 3 - adduser postgres
- passwd postgres (set to postgres)
- chown postgres /var/lib/pqsql/data
- /usr/bin/initdb -D /var/lib/pgsql/data
- /usr/bin/postmaster -D /var/lib/pgsql/data logfile
21 
- createdb test postgres
- psql test
create table testdata (id int not null primary key,
foo varchar(25), bar int);
insert into testdata values(1, 'hello', 12345);
- Update server.xml with this under the /Host tag:
Resource name=jdbc/postgres auth=Container
 type=javax.sql.DataSource
driverClassName=org.postgresql.Driver
 url=jdbc:postgresql://127.0.0.1:5432/mydb
 username=postgres password=postgres
maxActive=20 maxIdle=10 maxWait=-1/
/Context
cd /usr/local/jakarta-tomcat-5.5.7/common/lib
- wget
http://cvs.apache.org/builds/jakarta-taglibs/nightly/jakarta-taglibs-20050303.tar.gz
- tar xzf jakarta-taglibs-20050303.tar.gz
- mkdir /var/www/webapps/dbtest
- vi /var/www/webapps/dbtest/test.jsp (I put the
example code here)
Here it is just in case:

%@ taglib uri=http://java.sun.com/jsp/jstl/sql;
prefix=sql %
%@ taglib uri=http://java.sun.com/jsp/jstl/core;
prefix=c %
sql:query var=rs dataSource=jdbc/TestDB
select id, foo, bar from testdata
/sql:query
html
 head
   titleDB Test/title
 /head
 body
 h2Results/h2
 
c:forEach var=row items=${rs.rows}
   Foo ${row.foo}br/
   Bar ${row.bar}br/
/c:forEach

 /body
/html
- mkdir /var/www/webapps/dbtest/WEB-INF/
- vi /var/www/webapps/dbtest/WEB-INF/web.xml
I have the following in web.xml
web-app xmlns=http://java.sun.com/xml/ns/j2ee;
  
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
  
xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd;
   version=2.4
 descriptionPostgre Test App/description
 resource-ref
 descriptionDB Connection/description
 res-ref-namejdbc/test/res-ref-name
 res-typejavax.sql.DataSource/res-type
 res-authContainer/res-auth
 /resource-ref
/web-app

I now copy the necessary tag libraries over to the
application directory:
- mkdir /var/www/webapps/dbtest/WEB-INF/lib
- cp
/usr/local/jakarta-tomcat-5.5.7/common/lib/jakarta-taglibs/standard/lib/jstl.jar
standard.jar /var/www/webapps/dbtest/WEB-INF/lib
- cp
/usr/local/jakarta-tomcat-5.5.7/common/lib/jakarta-taglibs/standard/tld/*
/var/www/webapps/dbtest/WEB-INF
- catalina.sh run
- http://localhost:8080/dbtest/test.jsp
- And the console gives the following:
[EMAIL PROTECTED] local]# catalina.sh run
Using CATALINA_BASE:   /usr/local/jakarta-tomcat-5.5.7
Using CATALINA_HOME:   /usr/local/jakarta-tomcat-5.5.7
Using CATALINA_TMPDIR:
/usr/local/jakarta-tomcat-5.5.7/temp
Using JRE_HOME:   /usr/java/jdk1.5.0
Mar 3, 2005 10:22:45 PM
org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Mar 3, 2005 10:22:45 PM
org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1106 ms
Mar 3, 2005 10:22:45 PM
org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Mar 3, 2005 10:22:45 PM
org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.7
Mar 3, 2005 10:22:45 PM
org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Mar 3, 2005 10:22:46 PM
org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Mar 3, 2005 10:22:46 PM
org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
Mar 3, 2005 10:22:46 PM org.apache.jk.server.JkMain
start
INFO: Jk running ID=0 time=0/142  config=null
Mar 3, 2005 10:22:47 PM
org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath
resource
Mar 3, 2005 10:22:47 PM
org.apache.catalina.startup.Catalina start
INFO: Server startup in 1701 ms
Mar 3, 2005 10:23:29 PM
org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw
exception
javax.servlet.jsp.JspException: Unable to get
connection, DataSource invalid:
java.sql.SQLException: No suitable driver
   at
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(Unknown
Source)
   at
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(Unknown
Source)
   at
org.apache.jsp.test_jsp._jspx_meth_sql_query_0(org.apache.jsp.test_jsp:101)
   at
org.apache.jsp.test_jsp._jspService(org.apache.jsp.test_jsp:58)
 

Re: Tomcat 5.5.8 Postgresql 7.4.6 No suitable driver exception

2005-03-04 Thread Ole Ersoy
David,

I downloaded it and un-zipped it here:

 cd /usr/local/jakarta-tomcat-5.5.7/common/lib
- wget
http://cvs.apache.org/builds/jakarta-taglibs/nightly/jakarta-taglibs-20050303.tar.gz
- tar xzf jakarta-taglibs-20050303.tar.gz

I've tried both type two and type 3 drivers, since the
example was a bit vague on which driver is currently
supported by DBCP.

Thanks though,
- Ole
--- David Smith [EMAIL PROTECTED] wrote:

 One of the only things I don't see here -- and it's
 a big one -- no 
 postgresql jdbc driver in common/lib.  Tomcat
 doesn't come with it by 
 default.  You have to download the latest and
 install it before this 
 will work.
 
 --David
 
 Ole Ersoy wrote:
 
 Hi everybody,
 
 I'm attempting to get the JNDI Datasource How To
 example for Postgresql to work.
 
 Here is the URL for the example:

http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
 
 After completing the listed steps the test.jsp
 error
 page reports:
 java.sql.SQLException: No suitable driver
 
 Here are all my configuration steps, including the
 files:
 - On Fedora Core 3 - adduser postgres
 - passwd postgres (set to postgres)
 - chown postgres /var/lib/pqsql/data
 - /usr/bin/initdb -D /var/lib/pgsql/data
 - /usr/bin/postmaster -D /var/lib/pgsql/data
 logfile
 21 
 - createdb test postgres
 - psql test
 create table testdata (id int not null primary key,
 foo varchar(25), bar int);
 insert into testdata values(1, 'hello', 12345);
 - Update server.xml with this under the /Host
 tag:
 Resource name=jdbc/postgres auth=Container
   type=javax.sql.DataSource
 driverClassName=org.postgresql.Driver
  
 url=jdbc:postgresql://127.0.0.1:5432/mydb
   username=postgres password=postgres
 maxActive=20 maxIdle=10 maxWait=-1/
 /Context
  cd /usr/local/jakarta-tomcat-5.5.7/common/lib
 - wget

http://cvs.apache.org/builds/jakarta-taglibs/nightly/jakarta-taglibs-20050303.tar.gz
 - tar xzf jakarta-taglibs-20050303.tar.gz
 - mkdir /var/www/webapps/dbtest
 - vi /var/www/webapps/dbtest/test.jsp (I put the
 example code here)
 Here it is just in case:
  
 
 %@ taglib uri=http://java.sun.com/jsp/jstl/sql;
 prefix=sql %
 %@ taglib uri=http://java.sun.com/jsp/jstl/core;
 prefix=c %
 
 sql:query var=rs dataSource=jdbc/TestDB
 select id, foo, bar from testdata
 /sql:query
 
 html
   head
 titleDB Test/title
   /head
   body
 
   h2Results/h2
   
 c:forEach var=row items=${rs.rows}
 Foo ${row.foo}br/
 Bar ${row.bar}br/
 /c:forEach
 
   /body
 /html
 
 - mkdir /var/www/webapps/dbtest/WEB-INF/
 - vi /var/www/webapps/dbtest/WEB-INF/web.xml
 
 I have the following in web.xml
 web-app xmlns=http://java.sun.com/xml/ns/j2ee;


xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;

 xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd;
 version=2.4
   descriptionPostgre Test App/description
   resource-ref
   descriptionDB Connection/description
   res-ref-namejdbc/test/res-ref-name
   res-typejavax.sql.DataSource/res-type
   res-authContainer/res-auth
   /resource-ref
 /web-app
 
 I now copy the necessary tag libraries over to the
 application directory:
 - mkdir /var/www/webapps/dbtest/WEB-INF/lib
 - cp

/usr/local/jakarta-tomcat-5.5.7/common/lib/jakarta-taglibs/standard/lib/jstl.jar
 standard.jar /var/www/webapps/dbtest/WEB-INF/lib
 - cp

/usr/local/jakarta-tomcat-5.5.7/common/lib/jakarta-taglibs/standard/tld/*
 /var/www/webapps/dbtest/WEB-INF
 
 - catalina.sh run
 - http://localhost:8080/dbtest/test.jsp
 - And the console gives the following:
 
 [EMAIL PROTECTED] local]# catalina.sh run
 Using CATALINA_BASE:  
 /usr/local/jakarta-tomcat-5.5.7
 Using CATALINA_HOME:  
 /usr/local/jakarta-tomcat-5.5.7
 Using CATALINA_TMPDIR:
 /usr/local/jakarta-tomcat-5.5.7/temp
 Using JRE_HOME:   /usr/java/jdk1.5.0
 Mar 3, 2005 10:22:45 PM
 org.apache.coyote.http11.Http11Protocol init
 INFO: Initializing Coyote HTTP/1.1 on http-8080
 Mar 3, 2005 10:22:45 PM
 org.apache.catalina.startup.Catalina load
 INFO: Initialization processed in 1106 ms
 Mar 3, 2005 10:22:45 PM
 org.apache.catalina.core.StandardService start
 INFO: Starting service Catalina
 Mar 3, 2005 10:22:45 PM
 org.apache.catalina.core.StandardEngine start
 INFO: Starting Servlet Engine: Apache Tomcat/5.5.7
 Mar 3, 2005 10:22:45 PM
 org.apache.catalina.core.StandardHost start
 INFO: XML validation disabled
 Mar 3, 2005 10:22:46 PM
 org.apache.coyote.http11.Http11Protocol start
 INFO: Starting Coyote HTTP/1.1 on http-8080
 Mar 3, 2005 10:22:46 PM
 org.apache.jk.common.ChannelSocket init
 INFO: JK2: ajp13 listening on /0.0.0.0:8009
 Mar 3, 2005 10:22:46 PM org.apache.jk.server.JkMain
 start
 INFO: Jk running ID=0 time=0/142  config=null
 Mar 3, 2005 10:22:47 PM
 org.apache.catalina.storeconfig.StoreLoader load
 INFO: Find registry server-registry.xml at
 classpath
 resource
 Mar 3, 2005 10:22:47 PM
 org.apache.catalina.startup.Catalina start
 INFO: Server startup in 1701 

Re: Tomcat 5.5.8 Postgresql 7.4.6 No suitable driver exception

2005-03-04 Thread Ole Ersoy
Sorry - wrong wget lines - I meant to provide this
statement:
wget
http://jdbc.postgresql.org/download/pg74.215.jdbc2.jar

I then untarred it in the common lib directory.  I
tried both the type 2 and type 3 driver.

Thanks,
- Ole
--- Ole Ersoy [EMAIL PROTECTED] wrote:

 David,
 
 I downloaded it and un-zipped it here:
 
  cd /usr/local/jakarta-tomcat-5.5.7/common/lib
 - wget

http://cvs.apache.org/builds/jakarta-taglibs/nightly/jakarta-taglibs-20050303.tar.gz
 - tar xzf jakarta-taglibs-20050303.tar.gz
 
 I've tried both type two and type 3 drivers, since
 the
 example was a bit vague on which driver is currently
 supported by DBCP.
 
 Thanks though,
 - Ole
 --- David Smith [EMAIL PROTECTED] wrote:
 
  One of the only things I don't see here -- and
 it's
  a big one -- no 
  postgresql jdbc driver in common/lib.  Tomcat
  doesn't come with it by 
  default.  You have to download the latest and
  install it before this 
  will work.
  
  --David
  
  Ole Ersoy wrote:
  
  Hi everybody,
  
  I'm attempting to get the JNDI Datasource How To
  example for Postgresql to work.
  
  Here is the URL for the example:
 

http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
  
  After completing the listed steps the test.jsp
  error
  page reports:
  java.sql.SQLException: No suitable driver
  
  Here are all my configuration steps, including
 the
  files:
  - On Fedora Core 3 - adduser postgres
  - passwd postgres (set to postgres)
  - chown postgres /var/lib/pqsql/data
  - /usr/bin/initdb -D /var/lib/pgsql/data
  - /usr/bin/postmaster -D /var/lib/pgsql/data
  logfile
  21 
  - createdb test postgres
  - psql test
  create table testdata (id int not null primary
 key,
  foo varchar(25), bar int);
  insert into testdata values(1, 'hello', 12345);
  - Update server.xml with this under the /Host
  tag:
  Resource name=jdbc/postgres auth=Container
type=javax.sql.DataSource
  driverClassName=org.postgresql.Driver
   
  url=jdbc:postgresql://127.0.0.1:5432/mydb
username=postgres password=postgres
  maxActive=20 maxIdle=10 maxWait=-1/
  /Context
   cd /usr/local/jakarta-tomcat-5.5.7/common/lib
  - wget
 

http://cvs.apache.org/builds/jakarta-taglibs/nightly/jakarta-taglibs-20050303.tar.gz
  - tar xzf jakarta-taglibs-20050303.tar.gz
  - mkdir /var/www/webapps/dbtest
  - vi /var/www/webapps/dbtest/test.jsp (I put the
  example code here)
  Here it is just in case:
 
  
  %@ taglib uri=http://java.sun.com/jsp/jstl/sql;
  prefix=sql %
  %@ taglib
 uri=http://java.sun.com/jsp/jstl/core;
  prefix=c %
  
  sql:query var=rs dataSource=jdbc/TestDB
  select id, foo, bar from testdata
  /sql:query
  
  html
head
  titleDB Test/title
/head
body
  
h2Results/h2

  c:forEach var=row items=${rs.rows}
  Foo ${row.foo}br/
  Bar ${row.bar}br/
  /c:forEach
  
/body
  /html
  
  - mkdir /var/www/webapps/dbtest/WEB-INF/
  - vi /var/www/webapps/dbtest/WEB-INF/web.xml
  
  I have the following in web.xml
  web-app xmlns=http://java.sun.com/xml/ns/j2ee;
 
 

xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
 
 
 xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
  http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd;
  version=2.4
descriptionPostgre Test App/description
resource-ref
descriptionDB Connection/description
res-ref-namejdbc/test/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth
/resource-ref
  /web-app
  
  I now copy the necessary tag libraries over to
 the
  application directory:
  - mkdir /var/www/webapps/dbtest/WEB-INF/lib
  - cp
 

/usr/local/jakarta-tomcat-5.5.7/common/lib/jakarta-taglibs/standard/lib/jstl.jar
  standard.jar /var/www/webapps/dbtest/WEB-INF/lib
  - cp
 

/usr/local/jakarta-tomcat-5.5.7/common/lib/jakarta-taglibs/standard/tld/*
  /var/www/webapps/dbtest/WEB-INF
  
  - catalina.sh run
  - http://localhost:8080/dbtest/test.jsp
  - And the console gives the following:
  
  [EMAIL PROTECTED] local]# catalina.sh run
  Using CATALINA_BASE:  
  /usr/local/jakarta-tomcat-5.5.7
  Using CATALINA_HOME:  
  /usr/local/jakarta-tomcat-5.5.7
  Using CATALINA_TMPDIR:
  /usr/local/jakarta-tomcat-5.5.7/temp
  Using JRE_HOME:   /usr/java/jdk1.5.0
  Mar 3, 2005 10:22:45 PM
  org.apache.coyote.http11.Http11Protocol init
  INFO: Initializing Coyote HTTP/1.1 on http-8080
  Mar 3, 2005 10:22:45 PM
  org.apache.catalina.startup.Catalina load
  INFO: Initialization processed in 1106 ms
  Mar 3, 2005 10:22:45 PM
  org.apache.catalina.core.StandardService start
  INFO: Starting service Catalina
  Mar 3, 2005 10:22:45 PM
  org.apache.catalina.core.StandardEngine start
  INFO: Starting Servlet Engine: Apache
 Tomcat/5.5.7
  Mar 3, 2005 10:22:45 PM
  org.apache.catalina.core.StandardHost start
  INFO: XML validation disabled
  Mar 3, 2005 10:22:46 PM
  org.apache.coyote.http11.Http11Protocol start
  INFO: Starting Coyote HTTP/1.1 on http-8080
  Mar 3, 2005 

Re: Tomcat 5.5.8 Postgresql 7.4.6 No suitable driver exception

2005-03-04 Thread Parsons Technical Services
Your update to the server.xml must be one of two way.
Declare it in a context tag set or in a GlobalResource tag set.
If done in a GlobalResource then a ResourceLink is also needed.
If you don't declare your context in the server.xml, you can declare your 
resource in your context tag that resides in your app. This will make it 
available to your app only.

I think there is a typo on the page. I believe that it must be declared 
inside a context pair. The page text lead one to think it only has to be 
inside the host tags.

http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html#Database%20Connection%20Pool%20(DBCP)%20Configurations
Doug
- Original Message - 
From: Ole Ersoy [EMAIL PROTECTED]
To: Tomcat Users List tomcat-user@jakarta.apache.org
Sent: Friday, March 04, 2005 9:45 AM
Subject: Re: Tomcat 5.5.8 Postgresql 7.4.6 No suitable driver exception


Sorry - wrong wget lines - I meant to provide this
statement:
wget
http://jdbc.postgresql.org/download/pg74.215.jdbc2.jar
I then untarred it in the common lib directory.  I
tried both the type 2 and type 3 driver.
Thanks,
- Ole
--- Ole Ersoy [EMAIL PROTECTED] wrote:
David,
I downloaded it and un-zipped it here:
 cd /usr/local/jakarta-tomcat-5.5.7/common/lib
- wget
http://cvs.apache.org/builds/jakarta-taglibs/nightly/jakarta-taglibs-20050303.tar.gz
- tar xzf jakarta-taglibs-20050303.tar.gz
I've tried both type two and type 3 drivers, since
the
example was a bit vague on which driver is currently
supported by DBCP.
Thanks though,
- Ole
--- David Smith [EMAIL PROTECTED] wrote:
 One of the only things I don't see here -- and
it's
 a big one -- no
 postgresql jdbc driver in common/lib.  Tomcat
 doesn't come with it by
 default.  You have to download the latest and
 install it before this
 will work.

 --David

 Ole Ersoy wrote:

 Hi everybody,
 
 I'm attempting to get the JNDI Datasource How To
 example for Postgresql to work.
 
 Here is the URL for the example:

http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
 
 After completing the listed steps the test.jsp
 error
 page reports:
 java.sql.SQLException: No suitable driver
 
 Here are all my configuration steps, including
the
 files:
 - On Fedora Core 3 - adduser postgres
 - passwd postgres (set to postgres)
 - chown postgres /var/lib/pqsql/data
 - /usr/bin/initdb -D /var/lib/pgsql/data
 - /usr/bin/postmaster -D /var/lib/pgsql/data
 logfile
 21 
 - createdb test postgres
 - psql test
 create table testdata (id int not null primary
key,
 foo varchar(25), bar int);
 insert into testdata values(1, 'hello', 12345);
 - Update server.xml with this under the /Host
 tag:
 Resource name=jdbc/postgres auth=Container
   type=javax.sql.DataSource
 driverClassName=org.postgresql.Driver
 
 url=jdbc:postgresql://127.0.0.1:5432/mydb
   username=postgres password=postgres
 maxActive=20 maxIdle=10 maxWait=-1/
 /Context
  cd /usr/local/jakarta-tomcat-5.5.7/common/lib
 - wget

http://cvs.apache.org/builds/jakarta-taglibs/nightly/jakarta-taglibs-20050303.tar.gz
 - tar xzf jakarta-taglibs-20050303.tar.gz
 - mkdir /var/www/webapps/dbtest
 - vi /var/www/webapps/dbtest/test.jsp (I put the
 example code here)
 Here it is just in case:
 
 
 %@ taglib uri=http://java.sun.com/jsp/jstl/sql;
 prefix=sql %
 %@ taglib
uri=http://java.sun.com/jsp/jstl/core;
 prefix=c %
 
 sql:query var=rs dataSource=jdbc/TestDB
 select id, foo, bar from testdata
 /sql:query
 
 html
   head
 titleDB Test/title
   /head
   body
 
   h2Results/h2
 
 c:forEach var=row items=${rs.rows}
 Foo ${row.foo}br/
 Bar ${row.bar}br/
 /c:forEach
 
   /body
 /html
 
 - mkdir /var/www/webapps/dbtest/WEB-INF/
 - vi /var/www/webapps/dbtest/WEB-INF/web.xml
 
 I have the following in web.xml
 web-app xmlns=http://java.sun.com/xml/ns/j2ee;
 

xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
 

xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd;
 version=2.4
   descriptionPostgre Test App/description
   resource-ref
   descriptionDB Connection/description
   res-ref-namejdbc/test/res-ref-name
   res-typejavax.sql.DataSource/res-type
   res-authContainer/res-auth
   /resource-ref
 /web-app
 
 I now copy the necessary tag libraries over to
the
 application directory:
 - mkdir /var/www/webapps/dbtest/WEB-INF/lib
 - cp

/usr/local/jakarta-tomcat-5.5.7/common/lib/jakarta-taglibs/standard/lib/jstl.jar
 standard.jar /var/www/webapps/dbtest/WEB-INF/lib
 - cp

/usr/local/jakarta-tomcat-5.5.7/common/lib/jakarta-taglibs/standard/tld/*
 /var/www/webapps/dbtest/WEB-INF
 
 - catalina.sh run
 - http://localhost:8080/dbtest/test.jsp
 - And the console gives the following:
 
 [EMAIL PROTECTED] local]# catalina.sh run
 Using CATALINA_BASE:
 /usr/local/jakarta-tomcat-5.5.7
 Using CATALINA_HOME:
 /usr/local/jakarta-tomcat-5.5.7
 Using CATALINA_TMPDIR:
 /usr/local/jakarta-tomcat-5.5.7/temp
 Using JRE_HOME:   /usr/java/jdk1.5.0
 Mar

Tomcat 5.5.8 Postgresql 7.4.6 No suitable driver exception

2005-03-03 Thread Ole Ersoy
Hi everybody,

I'm attempting to get the JNDI Datasource How To
example for Postgresql to work.

Here is the URL for the example:
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html

After completing the listed steps the test.jsp error
page reports:
java.sql.SQLException: No suitable driver

Here are all my configuration steps, including the
files:
- On Fedora Core 3 - adduser postgres
- passwd postgres (set to postgres)
- chown postgres /var/lib/pqsql/data
- /usr/bin/initdb -D /var/lib/pgsql/data
- /usr/bin/postmaster -D /var/lib/pgsql/data logfile
21 
- createdb test postgres
- psql test
create table testdata (id int not null primary key,
foo varchar(25), bar int);
insert into testdata values(1, 'hello', 12345);
- Update server.xml with this under the /Host tag:
Resource name=jdbc/postgres auth=Container
  type=javax.sql.DataSource
driverClassName=org.postgresql.Driver
  url=jdbc:postgresql://127.0.0.1:5432/mydb
  username=postgres password=postgres
maxActive=20 maxIdle=10 maxWait=-1/
/Context
 cd /usr/local/jakarta-tomcat-5.5.7/common/lib
- wget
http://cvs.apache.org/builds/jakarta-taglibs/nightly/jakarta-taglibs-20050303.tar.gz
- tar xzf jakarta-taglibs-20050303.tar.gz
- mkdir /var/www/webapps/dbtest
- vi /var/www/webapps/dbtest/test.jsp (I put the
example code here)
Here it is just in case:


%@ taglib uri=http://java.sun.com/jsp/jstl/sql;
prefix=sql %
%@ taglib uri=http://java.sun.com/jsp/jstl/core;
prefix=c %

sql:query var=rs dataSource=jdbc/TestDB
select id, foo, bar from testdata
/sql:query

html
  head
titleDB Test/title
  /head
  body

  h2Results/h2
  
c:forEach var=row items=${rs.rows}
Foo ${row.foo}br/
Bar ${row.bar}br/
/c:forEach

  /body
/html

- mkdir /var/www/webapps/dbtest/WEB-INF/
- vi /var/www/webapps/dbtest/WEB-INF/web.xml

I have the following in web.xml
web-app xmlns=http://java.sun.com/xml/ns/j2ee;
   
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
   
xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd;
version=2.4
  descriptionPostgre Test App/description
  resource-ref
  descriptionDB Connection/description
  res-ref-namejdbc/test/res-ref-name
  res-typejavax.sql.DataSource/res-type
  res-authContainer/res-auth
  /resource-ref
/web-app

I now copy the necessary tag libraries over to the
application directory:
- mkdir /var/www/webapps/dbtest/WEB-INF/lib
- cp
/usr/local/jakarta-tomcat-5.5.7/common/lib/jakarta-taglibs/standard/lib/jstl.jar
standard.jar /var/www/webapps/dbtest/WEB-INF/lib
- cp
/usr/local/jakarta-tomcat-5.5.7/common/lib/jakarta-taglibs/standard/tld/*
/var/www/webapps/dbtest/WEB-INF

- catalina.sh run
- http://localhost:8080/dbtest/test.jsp
- And the console gives the following:

[EMAIL PROTECTED] local]# catalina.sh run
Using CATALINA_BASE:   /usr/local/jakarta-tomcat-5.5.7
Using CATALINA_HOME:   /usr/local/jakarta-tomcat-5.5.7
Using CATALINA_TMPDIR:
/usr/local/jakarta-tomcat-5.5.7/temp
Using JRE_HOME:   /usr/java/jdk1.5.0
Mar 3, 2005 10:22:45 PM
org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Mar 3, 2005 10:22:45 PM
org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1106 ms
Mar 3, 2005 10:22:45 PM
org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Mar 3, 2005 10:22:45 PM
org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.7
Mar 3, 2005 10:22:45 PM
org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Mar 3, 2005 10:22:46 PM
org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Mar 3, 2005 10:22:46 PM
org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
Mar 3, 2005 10:22:46 PM org.apache.jk.server.JkMain
start
INFO: Jk running ID=0 time=0/142  config=null
Mar 3, 2005 10:22:47 PM
org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath
resource
Mar 3, 2005 10:22:47 PM
org.apache.catalina.startup.Catalina start
INFO: Server startup in 1701 ms
Mar 3, 2005 10:23:29 PM
org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw
exception
javax.servlet.jsp.JspException: Unable to get
connection, DataSource invalid:
java.sql.SQLException: No suitable driver
at
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(Unknown
Source)
at
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(Unknown
Source)
at
org.apache.jsp.test_jsp._jspx_meth_sql_query_0(org.apache.jsp.test_jsp:101)
at
org.apache.jsp.test_jsp._jspService(org.apache.jsp.test_jsp:58)
at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at