Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-11 Thread peter . catania

hello Przemyslaw, les,

>On Wed, 03 Jul 2002 05:11:44 -0700 , Przemyslaw wrote:
>On Tuesday 02 July 2002 16:27, Les Hughes wrote:
>> Ok. Summary time.
>>
>> Martin reflects my experience - I dumped tyrex and used DBCP as well. But
>> aren't we trying to go direct without a pool? Having said that I've only
>> ever managed to get datasources working when DBCP is being used...
>>
>> Check that your driver jarfile does not contain the javax.sql extension
>> classes. If it does, delete them and rejar. Some versions of Tomcat will
>> ignore any jar that has these classes present. Be careful with this
thought
>> - I work with jdk1.4 which has these built in.
>>
>> Also, you don't specify a DataSourceFactory in your server.xml - see
below.
>>
>>
>> Here's a known (well as far as I know...) good postgres solution using
>> DBCP.
>
>And that's the path I'll follow. Despite huge support from the list (I
applied 
>all suggested changes and patches) I was unable to make it work. Now I will

>try to understand the new model of DBCP.
>
>Thank you all for your support.
>
>przem

i checked your idea to use DBCP and it is working, but i was not
willing to give up on the problem.

so i entered exactly the same jndi url as read on your example
and voila no problem. so it seems we are not read the complete
naming conventions or did not understand the doc. i could not
find a hint what you have to type:

 java:comp/env/jdbc/Database instead of jdbc/Database.
  
^
so for now it's solved and i went back to find out what
is better with DBCP.

BTW: i changed server.xml and global web.xml !!

best reagrds
 peter ;-)

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-04 Thread Les Hughes


The model is very simple and as a "coder" you never see that DBCP is there
instead of Tyrex or a direct connection.

Let me know how you get on an I'll patch the documentation accordingly. Also
I noticed that my howto has made it into CVS (thanks guys!) so if you grab a
nightly build (probably tomorrow now) then you can follow those
instructions.

Good luck!

Les



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-03 Thread Przemyslaw Kowalczyk

On Tuesday 02 July 2002 16:27, Les Hughes wrote:
> Ok. Summary time.
>
> Martin reflects my experience - I dumped tyrex and used DBCP as well. But
> aren't we trying to go direct without a pool? Having said that I've only
> ever managed to get datasources working when DBCP is being used...
>
> Check that your driver jarfile does not contain the javax.sql extension
> classes. If it does, delete them and rejar. Some versions of Tomcat will
> ignore any jar that has these classes present. Be careful with this thought
> - I work with jdk1.4 which has these built in.
>
> Also, you don't specify a DataSourceFactory in your server.xml - see below.
>
>
> Here's a known (well as far as I know...) good postgres solution using
> DBCP.

And that's the path I'll follow. Despite huge support from the list (I applied 
all suggested changes and patches) I was unable to make it work. Now I will 
try to understand the new model of DBCP.

Thank you all for your support.

przem


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread Nikola Milutinovic

> Neither adding description nor removing slashes helped.
> I've checked the path in manual:
> jdbc:postgresql:database
> jdbc:postgresql://host/database
> jdbc:postgresql://host:port/database

This last form is the most complete one. Anyway, that will not make a difference, 
since it is up to JDBC driver to parse this URL AND JDBC DRIVER WORKS.

> I wonder if there is a way to debug what exactly Tomcat does. What section of 
> server.xml does it parse etc.

I've tried running Tomcat under JBuilder. I did get into debugging session, but when 
it came to XML parser, it just, sort of, dropped into a hole. I needed sources for XML 
parser, too. At that point I've had had too much and decided to wait for DBCP.

> Does anyone tried to connect to postgresql and succeeded?

Craig has done it and although he is one of the developers, he was unable to help us. 
I guess it is not just for fashion, that they have decided to drop Tyrex in favour of 
DBCP.

Nix.



Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread Arshad Mahmood

Hi,

I notice that you are doing the JDBC lookup in the "init" function. This
doesn't appear to work properly (at least on 4.1.6), move the initialisation
code to the "doGet/doPost" and see if that helps. This cured my JNDI/JDBC
problems.

Regards.

- Original Message -
From: "Przemyslaw Kowalczyk" <[EMAIL PROTECTED]>
To: "'Tomcat Users List'" <[EMAIL PROTECTED]>
Sent: Tuesday, July 02, 2002 11:08 AM
Subject: Tomcat 4.0.4, jndi, jdbc and postgresql [long]


> Hi
>
> I've just started to write servlets. Servlets that only do processing,
without
> connecting to database work fine, but I have some problems to get the
> connection with postgresql via jdbc work.
>
> Tomcat: 4.0.4 (on linux)
> Postgresql: 7.2.1 (on linux)
> Jdbc: pgjdbc2.jar (from jdbc.postgresql.org)
>
> The servlet is quite simple:
>
> import java.io.*;
> import java.util.*;
> import java.sql.*;
> import javax.sql.*;
> import javax.naming.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public class InfoServlet extends HttpServlet {
>
> Connection con;
> private boolean conFree = true;
>
> public void init() throws ServletException {
> try  {
> Context initCtx = new InitialContext();
> Context envCtx =
> (Context)initCtx.lookup("java:comp/env");
> DataSource ds = (DataSource)
> envCtx.lookup("jdbc/BookDB");
> Connection con = ds.getConnection();
> } catch (Exception ex) {
> throw new ServletException("Couldn't open
connection
> to database: " + ex.getMessage());
> }
> }
>
> public void destroy() {
> try {
> con.close();
> } catch (SQLException ex) {
> System.out.println(ex.getMessage());
> }
> }
>
> public void doGet (HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException {
>
> HttpSession session = request.getSession();
>
> // set content-type header before accessing the Writer
> response.setContentType("text/html");
> response.setBufferSize(8192);
> PrintWriter out = response.getWriter();
>
> // then write the data of the response
> out.println("" +
> "Duke's Bookstore");
> }
> }
>
> in web/WEB-INF/web.xml I defined:
>
>
>  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> "http://java.sun.com/dtd/web-app_2_3.dtd";>
> 
> Currency Converter Application
> 
> Test servlet
> 
> 
> info
> info
> no description
> InfoServlet
> 
> 
> info
> /info
> 
> 
> 30
> 
> 
> jdbc/BookDB
> javax.sql.DataSource
> Containter
> 
> 
>
> And in server.xml in the contex of the application:
>
>  reloadable="true" crossContext="true">
> prefix="localhost_bookstore_log." suffix=".txt"
>   timestamp="true"/>
>type="javax.sql.DataSource"/>
>   
> 
>   user
>   java
> 
> 
>   password
>   java
> 
> 
>   driverClassName
>   org.postgresql.Driver
> 
> 
>   driverName
>   jdbc:postgresql:public
> 
>   
> 
>
> I've tried a few different driverName parameters: (restarting Tomcat after
> each change)
> jdbc:postgresql://localhost/public
> jdbc:postgresql://full.server.name/public
> jdbc:postgresql:public
> jdbc:postgresql://localhost/
>
> But, despite the parameters, I always get the following error:
>
> exception
> javax.servlet.ServletException: Couldn't open connection to database:
> Exception creating DataSource: org.hsql.jdbcDriver
> at InfoServlet.init(Unknown Source)
> at javax.servlet.GenericServlet.init(GenericServlet.java:258)
> at
>
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:91
8)
> 
>
> {cut}
>
> I have no idea why Tomcat wants to connect using hsql driver. I grepped
> through tomcat directory and found only one reference to this driver (in
> examples section). I removed event the sample section, restarted Tomcat
but
> it didn't help.
>
> Does anyone know what is wrong?
>
> regards
> Przem
>
>
> --
> To unsubscribe, e-mail:

> For additional commands, e-mail:

>
>


--
To unsubscribe, e-mail:   
For additio

Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread Brian P. Millett

On Tue, 2002-07-02 at 08:47, Przemyslaw Kowalczyk wrote:
> On Tuesday 02 July 2002 15:16, Les Hughes wrote:
> > Ignore the "remove //" comment - I was looking at my oracle notes :-)
> > I really have no idea why it's trying to load the hsql driver if there's no
> > ref in your
> > server.xml
> 
> Ok, the full versions (I cut off all comments):
> 
> przem

Przem,
 Here are the setting I have used with Tomcat 4.0.4, postgresql 7.2.1 &
jdk1.4

I had to put the postgresql.jar, commons-dbcp.jar, commons-pool.jar into
the /common/lib directory.

SERVER.XML:


  
  
 factory

org.apache.commons.dbcp.BasicDataSourceFactory

   
maxActive100
   
maxIdle3
   
maxWait100
   
usernameX
   
password

driverClassName
org.postgresql.Driver


url
   
jdbc:postgresql://localhost:5432/ids_tropicos

  

Then the web.xml cruft:

  PostgreSQL DB Connection
  jdbc/tropicos
  javax.sql.DataSource
  Container


-- 
Brian Millett
Enterprise Consulting Group   "Shifts in paradigms
(314) 205-9030   often cause nose bleeds."
[EMAIL PROTECTED]   Greg Glenn


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread Les Hughes


Ok. Summary time.

Martin reflects my experience - I dumped tyrex and used DBCP as well. But
aren't we trying to go direct without a pool? Having said that I've only
ever managed to get datasources working when DBCP is being used...

Check that your driver jarfile does not contain the javax.sql extension
classes. If it does, delete them and rejar. Some versions of Tomcat will
ignore any jar that has these classes present. Be careful with this thought
- I work with jdk1.4 which has these built in.

Also, you don't specify a DataSourceFactory in your server.xml - see below.


Here's a known (well as far as I know...) good postgres solution using DBCP.
See
http://marc.theaimsgroup.com/?l=tomcat-user&m=102225547106556&w=2
for my original mysql post as well.



 


  
factory
org.apache.commons.dbcp.BasicDataSourceFactory
  
  
driverClassName
org.postgresql.Driver
  
  
url
jdbc:postgresql://127.0.0.1:5432/mydb
  
  
username
myuser
  
  
password
mypasswd
  
  
maxActive
20
  
  
maxIdle
10
  
  
maxWait
-1
  
 




> -Original Message-
> From: Przemyslaw Kowalczyk [mailto:[EMAIL PROTECTED]]
> Sent: 02 July 2002 14:53
> To: Tomcat Users List
> Subject: Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]
> 
> 
> On Tuesday 02 July 2002 15:43, [EMAIL PROTECTED] wrote:
> > Do you have already connected to a postgresql db using a 
> java app? Are you
> > sure the parameters are correct? What is "public"? Where 
> did you put the
> > postgresql.jar?
> 
> Yes, without any problems from 'standalone' application. I'm 
> able to query and 
> update database, so parameters (url, username and password) are ok.
> 
> There is no postgresql.jar, only pgjdbc2.jar. I put it in 
> ${tomcat-root}/lib 
> directory.  I tried first to add a link named postgresql.jar 
> and then I've 
> renamed it but it didn't help :-(
> 
> > Do you have a file named hsql.jar? Can you remove it?
> 
> I don't have such file.
> 
> 
> przem
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread Przemyslaw Kowalczyk

On Tuesday 02 July 2002 15:43, [EMAIL PROTECTED] wrote:
> Do you have already connected to a postgresql db using a java app? Are you
> sure the parameters are correct? What is "public"? Where did you put the
> postgresql.jar?

Yes, without any problems from 'standalone' application. I'm able to query and 
update database, so parameters (url, username and password) are ok.

There is no postgresql.jar, only pgjdbc2.jar. I put it in ${tomcat-root}/lib 
directory.  I tried first to add a link named postgresql.jar and then I've 
renamed it but it didn't help :-(

> Do you have a file named hsql.jar? Can you remove it?

I don't have such file.


przem


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread Przemyslaw Kowalczyk

On Tuesday 02 July 2002 15:16, Les Hughes wrote:
> Ignore the "remove //" comment - I was looking at my oracle notes :-)
> I really have no idea why it's trying to load the hsql driver if there's no
> ref in your
> server.xml

Ok, the full versions (I cut off all comments):

przem


server.xml

---cut---here

  




  


  

  








  
  
  

 username
  java


  password
  java
   

  driverClassName
  org.postgresql.Driver


  driverName
  jdbc:postgresql:/localhost/public

  
 

  



  


  





  

  



  



---cut---here

web.xml

---cut---here
http://java.sun.com/dtd/web-app_2_3.dtd";>


Info Application

Just test application


info
info
no description
InfoServlet


info
/info


30


Database Connection
jdbc/BookDB
javax.sql.DataSource
Container


---cut---here---

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread Martin Jacobson

Les Hughes wrote:

> Ignore the "remove //" comment - I was looking at my oracle notes :-)
> I really have no idea why it's trying to load the hsql driver if there's no
> ref in your
> server.xml
> 
> Post your server.xml and web.xml and we'll both have a look.
> 

I struggled for weeks (on and off) trying to figure out why Tyrex ALWAYS 
tries to load the hsql driver - in vain.

Don't bother trying to get Tyrex to work - it just doesn't! (And neither 
does it pool connections) - you should try TC 4.1, which uses the 
jakarta-commons DBCP. DBCP works, and pools connections!

Martin



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread andre . powroznik

Do you have already connected to a postgresql db using a java app? Are you sure the 
parameters are correct? What is "public"?
Where did you put the postgresql.jar?
Do you have a file named hsql.jar? Can you remove it?

-Original Message-
From: Przemyslaw Kowalczyk [mailto:[EMAIL PROTECTED]]
Sent: 02 July 2002 12:09
To: 'Tomcat Users List'
Subject: Tomcat 4.0.4, jndi, jdbc and postgresql [long]


Hi

I've just started to write servlets. Servlets that only do processing, without 
connecting to database work fine, but I have some problems to get the 
connection with postgresql via jdbc work.

Tomcat: 4.0.4   (on linux)
Postgresql: 7.2.1 (on linux)
Jdbc: pgjdbc2.jar (from jdbc.postgresql.org)

The servlet is quite simple:

import java.io.*;
import java.util.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class InfoServlet extends HttpServlet {

Connection con;
private boolean conFree = true;

public void init() throws ServletException {
try  {
Context initCtx = new InitialContext();
Context envCtx = 
(Context)initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)
envCtx.lookup("jdbc/BookDB");
Connection con = ds.getConnection();
} catch (Exception ex) {
throw new ServletException("Couldn't open connection 
to database: " + ex.getMessage());
}
}

public void destroy() {
try {
con.close();
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
}

public void doGet (HttpServletRequest request, HttpServletResponse 
response) throws ServletException, IOException {

HttpSession session = request.getSession();

// set content-type header before accessing the Writer
response.setContentType("text/html");
response.setBufferSize(8192);
PrintWriter out = response.getWriter();

// then write the data of the response
out.println("" +
"Duke's Bookstore");
}
}

in web/WEB-INF/web.xml I defined:


http://java.sun.com/dtd/web-app_2_3.dtd";>

Currency Converter Application

Test servlet


info
info
no description
InfoServlet


info
/info


30


jdbc/BookDB
javax.sql.DataSource
Containter



And in server.xml in the contex of the application:

   
  
  
  

  user
  java


  password
  java


  driverClassName
  org.postgresql.Driver


  driverName
  jdbc:postgresql:public

  


I've tried a few different driverName parameters: (restarting Tomcat after 
each change)
jdbc:postgresql://localhost/public
jdbc:postgresql://full.server.name/public
jdbc:postgresql:public
jdbc:postgresql://localhost/

But, despite the parameters, I always get the following error:

exception 
javax.servlet.ServletException: Couldn't open connection to database: 
Exception creating DataSource: org.hsql.jdbcDriver
at InfoServlet.init(Unknown Source)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at 
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:918)


{cut}

I have no idea why Tomcat wants to connect using hsql driver. I grepped 
through tomcat directory and found only one reference to this driver (in 
examples section). I removed event the sample section, restarted Tomcat but 
it didn't help. 

Does anyone know what is wrong? 

regards
Przem


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 

 DISCLAIMER  
"This e-mail and any attachments thereto may contain information 
which is confidential and/or protected by intellectual property 
rights and are intended for the sole use of the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, 
total or partial reproduction, communication or distribution in any form) 
by persons other than the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either 
by telephone or by e-mail and delete the material from any computer. 
Thank you for your cooperation."


--
To unsubscribe, e-mail:   

Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread Przemyslaw Kowalczyk

On Tuesday 02 July 2002 15:06, Les Hughes wrote:
> 
>   
>   DB Connection
>   jdbc/TestDB
>   javax.sql.DataSource
>   Container
>   
> 
>
> The description is missing (but I dont have a DTD to had to tell whether
> this is optional) but other than that it's fine.

Neither adding description nor removing slashes helped.
I've checked the path in manual:
jdbc:postgresql:database
jdbc:postgresql://host/database
jdbc:postgresql://host:port/database

I wonder if there is a way to debug what exactly Tomcat does. What section of 
server.xml does it parse etc.

Does anyone tried to connect to postgresql and succeeded?

przem




--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread Les Hughes


Ignore the "remove //" comment - I was looking at my oracle notes :-)
I really have no idea why it's trying to load the hsql driver if there's no
ref in your
server.xml

Post your server.xml and web.xml and we'll both have a look.



> -Original Message-
> From: Przemyslaw Kowalczyk [mailto:[EMAIL PROTECTED]]
> Sent: 02 July 2002 14:13
> To: Tomcat Users List
> Subject: Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]
> 
> 
> On Tuesday 02 July 2002 15:00, [EMAIL PROTECTED] wrote:
> > Is this normal :
> >
> >   
> > jdbc/BookDB
> > javax.sql.DataSource
> > Containter
> > 
> >
> > More especially : Containter : CONTAINTER?
> >
> 
> You are right, there is a misseling, but correcting it didn't 
> help much :-(
> 
> I'm still curious why tomcat wants a hsql driver even though it's not 
> mentioned in any configuration file.
> 
> przem
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread Przemyslaw Kowalczyk

On Tuesday 02 July 2002 15:00, [EMAIL PROTECTED] wrote:
> Is this normal :
>
> 
> jdbc/BookDB
> javax.sql.DataSource
> Containter
> 
>
> More especially : Containter : CONTAINTER?
>

You are right, there is a misseling, but correcting it didn't help much :-(

I'm still curious why tomcat wants a hsql driver even though it's not 
mentioned in any configuration file.

przem




--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread Przemyslaw Kowalczyk

On Tuesday 02 July 2002 14:56, [EMAIL PROTECTED] wrote:
> Would you have other applications running in tomcat?

No, I've just started to learn, so there are other apps.

przem


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread Les Hughes

  
  
  DB Connection
  jdbc/TestDB
  javax.sql.DataSource
  Container
  


The description is missing (but I dont have a DTD to had to tell whether
this is optional) but other than that it's fine.

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: 02 July 2002 14:00
> To: [EMAIL PROTECTED]
> Subject: RE: Tomcat 4.0.4, jndi, jdbc and postgresql [long]
> 
> 
> Is this normal :
> 
> 
> jdbc/BookDB
> javax.sql.DataSource
> Containter
> 
> 
> More especially : Containter : CONTAINTER?
> 
> Andre Powroznik
> 
> -Original Message-
> From: Przemyslaw Kowalczyk [mailto:[EMAIL PROTECTED]]
> Sent: 02 July 2002 12:09
> To: 'Tomcat Users List'
> Subject: Tomcat 4.0.4, jndi, jdbc and postgresql [long]
> 
> 
> Hi
> 
> I've just started to write servlets. Servlets that only do 
> processing, without 
> connecting to database work fine, but I have some problems to get the 
> connection with postgresql via jdbc work.
> 
> Tomcat: 4.0.4 (on linux)
> Postgresql: 7.2.1 (on linux)
> Jdbc: pgjdbc2.jar (from jdbc.postgresql.org)
> 
> The servlet is quite simple:
> 
> import java.io.*;
> import java.util.*;
> import java.sql.*;
> import javax.sql.*;
> import javax.naming.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> 
> public class InfoServlet extends HttpServlet {
> 
> Connection con;
> private boolean conFree = true;
> 
> public void init() throws ServletException {
> try  {
> Context initCtx = new InitialContext();
> Context envCtx = 
> (Context)initCtx.lookup("java:comp/env");
> DataSource ds = (DataSource)
> envCtx.lookup("jdbc/BookDB");
> Connection con = ds.getConnection();
> } catch (Exception ex) {
> throw new ServletException("Couldn't 
> open connection 
> to database: " + ex.getMessage());
> }
> }
> 
> public void destroy() {
> try {
> con.close();
> } catch (SQLException ex) {
> System.out.println(ex.getMessage());
> }
> }
> 
> public void doGet (HttpServletRequest request, 
> HttpServletResponse 
> response) throws ServletException, IOException {
> 
> HttpSession session = request.getSession();
> 
> // set content-type header before accessing the Writer
> response.setContentType("text/html");
> response.setBufferSize(8192);
> PrintWriter out = response.getWriter();
> 
> // then write the data of the response
> out.println("" +
> "Duke's Bookstore");
> }
> }
> 
> in web/WEB-INF/web.xml I defined:
> 
> 
>  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> "http://java.sun.com/dtd/web-app_2_3.dtd";>
> 
> Currency Converter Application
> 
> Test servlet
> 
> 
> info
> info
> no description
> InfoServlet
> 
> 
> info
> /info
> 
> 
> 30
> 
> 
> jdbc/BookDB
> javax.sql.DataSource
> Containter
> 
> 
> 
> And in server.xml in the contex of the application:
> 
>  reloadable="true" crossContext="true">
> prefix="localhost_bookstore_log." suffix=".txt"
>   timestamp="true"/>
>type="javax.sql.DataSource"/>
>   
> 
>   user
>   java
> 
> 
>   password
>   java
> 
> 
>   driverClassName
>   org.postgresql.Driver
> 
> 
>   driverName
>   jdbc:postgresql:public
> 
>   
> 
> 
> I've tried a few different driverName parameters: (restarting 
> Tomcat after 
> each change)
> jdbc:postgresql://localhos

RE: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread Les Hughes


Yep :-)

Oh, I think there's a typo in the URL - remove the two "//" - this is all
driver specific so it's a case of RTM :-)

> -Original Message-
> From: Przemyslaw Kowalczyk [mailto:[EMAIL PROTECTED]]
> Sent: 02 July 2002 14:00
> To: Tomcat Users List
> Subject: Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]
> 
> 
> On Tuesday 02 July 2002 14:53, Przemyslaw Kowalczyk wrote:
> 
> I came to another conclusion. Even if there was some 
> reference to hsql driver 
> in my server.xml it shouldn't affect my own servlet, as it 
> uses its own 
> context. Am I right?
> 
> przem
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread andre . powroznik

Is this normal :

  
jdbc/BookDB
javax.sql.DataSource
Containter


More especially : Containter : CONTAINTER?

Andre Powroznik

-Original Message-
From: Przemyslaw Kowalczyk [mailto:[EMAIL PROTECTED]]
Sent: 02 July 2002 12:09
To: 'Tomcat Users List'
Subject: Tomcat 4.0.4, jndi, jdbc and postgresql [long]


Hi

I've just started to write servlets. Servlets that only do processing, without 
connecting to database work fine, but I have some problems to get the 
connection with postgresql via jdbc work.

Tomcat: 4.0.4   (on linux)
Postgresql: 7.2.1 (on linux)
Jdbc: pgjdbc2.jar (from jdbc.postgresql.org)

The servlet is quite simple:

import java.io.*;
import java.util.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class InfoServlet extends HttpServlet {

Connection con;
private boolean conFree = true;

public void init() throws ServletException {
try  {
Context initCtx = new InitialContext();
Context envCtx = 
(Context)initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)
envCtx.lookup("jdbc/BookDB");
Connection con = ds.getConnection();
} catch (Exception ex) {
throw new ServletException("Couldn't open connection 
to database: " + ex.getMessage());
}
}

public void destroy() {
try {
con.close();
} catch (SQLException ex) {
System.out.println(ex.getMessage());
}
}

public void doGet (HttpServletRequest request, HttpServletResponse 
response) throws ServletException, IOException {

HttpSession session = request.getSession();

// set content-type header before accessing the Writer
response.setContentType("text/html");
response.setBufferSize(8192);
PrintWriter out = response.getWriter();

// then write the data of the response
out.println("" +
"Duke's Bookstore");
}
}

in web/WEB-INF/web.xml I defined:


http://java.sun.com/dtd/web-app_2_3.dtd";>

Currency Converter Application

Test servlet


info
info
no description
InfoServlet


info
/info


30


jdbc/BookDB
javax.sql.DataSource
Containter



And in server.xml in the contex of the application:

   
  
  
  

  user
  java


  password
  java


  driverClassName
  org.postgresql.Driver


  driverName
  jdbc:postgresql:public

  


I've tried a few different driverName parameters: (restarting Tomcat after 
each change)
jdbc:postgresql://localhost/public
jdbc:postgresql://full.server.name/public
jdbc:postgresql:public
jdbc:postgresql://localhost/

But, despite the parameters, I always get the following error:

exception 
javax.servlet.ServletException: Couldn't open connection to database: 
Exception creating DataSource: org.hsql.jdbcDriver
at InfoServlet.init(Unknown Source)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at 
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:918)


{cut}

I have no idea why Tomcat wants to connect using hsql driver. I grepped 
through tomcat directory and found only one reference to this driver (in 
examples section). I removed event the sample section, restarted Tomcat but 
it didn't help. 

Does anyone know what is wrong? 

regards
Przem


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 

 DISCLAIMER  
"This e-mail and any attachments thereto may contain information 
which is confidential and/or protected by intellectual property 
rights and are intended for the sole use of the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, 
total or partial reproduction, communication or distribution in any form) 
by persons other than the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either 
by telephone or by e-mail and delete the material from any computer. 
Thank you for your cooperation."


--
To unsubscribe, e-mail:   
For additional comma

Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread Przemyslaw Kowalczyk

On Tuesday 02 July 2002 14:53, Przemyslaw Kowalczyk wrote:

I came to another conclusion. Even if there was some reference to hsql driver 
in my server.xml it shouldn't affect my own servlet, as it uses its own 
context. Am I right?

przem


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread andre . powroznik

Would you have other applications running in tomcat?

-Original Message-
From: Przemyslaw Kowalczyk [mailto:[EMAIL PROTECTED]]
Sent: 02 July 2002 14:54
To: Tomcat Users List
Subject: Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]


On Tuesday 02 July 2002 14:00, Les Hughes wrote:
> Two things,
>
> In your server.xml
> user I think should be username
> and
> driverName has been deprecated in favour of url which needs the servername
> and DB name as well
> (as in something like jdbc:postgresql://full.server.name/mybookdb <- or
> whatever the DB is called)

Ok. Now my configuration file looks as follows:


  
  
  

 username
  java


  password
  java


  driverClassName
  org.postgresql.Driver


  driverName
  jdbc:postgresql://willow.forest/public

  



> Are you *sure* you're using the right install of TC and that the server.xml
> has no reference to the hsql driver?

I'm absolutely sure. I even reinstalled whole tomcat (to cleanup everything)

> BTW - only got this working with Oracle and mySQL so most of this is
> guesswork based on those two exercises.
>
> Bye,
>
> Les
> P.S. You shouldn't open the connection in init() nor cache the connection
> BTW - use a pool instead :)

For sure I will, but now all that I want is to connect my servlet to database.

regards
przem

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

 DISCLAIMER  
"This e-mail and any attachments thereto may contain information 
which is confidential and/or protected by intellectual property 
rights and are intended for the sole use of the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, 
total or partial reproduction, communication or distribution in any form) 
by persons other than the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either 
by telephone or by e-mail and delete the material from any computer. 
Thank you for your cooperation."


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




Re: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread Przemyslaw Kowalczyk

On Tuesday 02 July 2002 14:00, Les Hughes wrote:
> Two things,
>
> In your server.xml
> user I think should be username
> and
> driverName has been deprecated in favour of url which needs the servername
> and DB name as well
> (as in something like jdbc:postgresql://full.server.name/mybookdb <- or
> whatever the DB is called)

Ok. Now my configuration file looks as follows:


  
  
  

 username
  java


  password
  java


  driverClassName
  org.postgresql.Driver


  driverName
  jdbc:postgresql://willow.forest/public

  



> Are you *sure* you're using the right install of TC and that the server.xml
> has no reference to the hsql driver?

I'm absolutely sure. I even reinstalled whole tomcat (to cleanup everything)

> BTW - only got this working with Oracle and mySQL so most of this is
> guesswork based on those two exercises.
>
> Bye,
>
> Les
> P.S. You shouldn't open the connection in init() nor cache the connection
> BTW - use a pool instead :)

For sure I will, but now all that I want is to connect my servlet to database.

regards
przem

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Tomcat 4.0.4, jndi, jdbc and postgresql [long]

2002-07-02 Thread Les Hughes


Two things,

In your server.xml
user I think should be username
and
driverName has been deprecated in favour of url which needs the servername
and DB name as well
(as in something like jdbc:postgresql://full.server.name/mybookdb <- or
whatever the DB is called)

Are you *sure* you're using the right install of TC and that the server.xml
has no reference to the hsql driver?

BTW - only got this working with Oracle and mySQL so most of this is
guesswork based on those two exercises. 

Bye,

Les
P.S. You shouldn't open the connection in init() nor cache the connection
BTW - use a pool instead :)

> -Original Message-
> From: Przemyslaw Kowalczyk [mailto:[EMAIL PROTECTED]]
> Sent: 02 July 2002 11:09
> To: 'Tomcat Users List'
> Subject: Tomcat 4.0.4, jndi, jdbc and postgresql [long]
> 
> 
> Hi
> 
> I've just started to write servlets. Servlets that only do 
> processing, without 
> connecting to database work fine, but I have some problems to get the 
> connection with postgresql via jdbc work.
> 
> Tomcat: 4.0.4 (on linux)
> Postgresql: 7.2.1 (on linux)
> Jdbc: pgjdbc2.jar (from jdbc.postgresql.org)
> 
> The servlet is quite simple:
> 
> import java.io.*;
> import java.util.*;
> import java.sql.*;
> import javax.sql.*;
> import javax.naming.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> 
> public class InfoServlet extends HttpServlet {
> 
> Connection con;
> private boolean conFree = true;
> 
> public void init() throws ServletException {
> try  {
> Context initCtx = new InitialContext();
> Context envCtx = 
> (Context)initCtx.lookup("java:comp/env");
> DataSource ds = (DataSource)
> envCtx.lookup("jdbc/BookDB");
> Connection con = ds.getConnection();
> } catch (Exception ex) {
> throw new ServletException("Couldn't 
> open connection 
> to database: " + ex.getMessage());
> }
> }
> 
> public void destroy() {
> try {
> con.close();
> } catch (SQLException ex) {
> System.out.println(ex.getMessage());
> }
> }
> 
> public void doGet (HttpServletRequest request, 
> HttpServletResponse 
> response) throws ServletException, IOException {
> 
> HttpSession session = request.getSession();
> 
> // set content-type header before accessing the Writer
> response.setContentType("text/html");
> response.setBufferSize(8192);
> PrintWriter out = response.getWriter();
> 
> // then write the data of the response
> out.println("" +
> "Duke's Bookstore");
> }
> }
> 
> in web/WEB-INF/web.xml I defined:
> 
> 
>  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> "http://java.sun.com/dtd/web-app_2_3.dtd";>
> 
> Currency Converter Application
> 
> Test servlet
> 
> 
> info
> info
> no description
> InfoServlet
> 
> 
> info
> /info
> 
> 
> 30
> 
> 
> jdbc/BookDB
> javax.sql.DataSource
> Containter
> 
> 
> 
> And in server.xml in the contex of the application:
> 
>  reloadable="true" crossContext="true">
> prefix="localhost_bookstore_log." suffix=".txt"
>   timestamp="true"/>
>type="javax.sql.DataSource"/>
>   
> 
>   user
>   java
> 
> 
>   password
>   java
> 
> 
>   driverClassName
>   org.postgresql.Driver
> 
> 
>   driverName
>   jdbc:postgresql:public
> 
>   
> 
> 
> I've tried a few different driverName parameters: (restarting 
> Tomcat after 
> each change)
> jdbc:postgresql://localhost/public
> jdbc:postgresql://full.server.name/public
> jdbc:postgresql:public
> jdbc:postgresql://localhost/
> 
> But, despite the parameters, I always get the following error:
> 
> exception 
> javax.servlet.ServletException: Couldn't open connection to database: 
> Exception creating DataSource: org.hsql.jdbcDriver
> at InfoServlet.init(Unknown Source)
> at javax.servlet.GenericServlet.init(GenericServlet.java:258)
> at 
> org.apache.catalina.core.StandardWrapper.loadServlet(StandardW
> rapper.java:918)
> 
> 
> {cut}
> 
> I have no idea why Tomcat wants to connect using hsql driver. 
> I grepped 
> through tomcat directory and found only