From: | "Gonzalo Aranda" <garanda(at)bitakora(dot)com> |
---|---|
To: | <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: tomcat +postgres THANKS |
Date: | 2002-03-21 08:25:13 |
Message-ID: | 000001c1d0b8$2113f340$b21ba8c0@wksagus |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
I try it all messages and It continue not working!!
Im going to reinstall tomcat......
Thanks for all your messages!!
----- Original Message -----
From: "Nikola Milutinovic" <Nikola(dot)Milutinovic(at)ev(dot)co(dot)yu>
To: "Gonzalo Aranda" <garanda(at)bitakora(dot)com>
Sent: Thursday, March 21, 2002 7:40 AM
Subject: Re: [JDBC] tomcat +postgres
> > I hve a problem with the tomcat which it doesnt find the postgres
drivers.
> > Anyone knows how and where I can fixit??
>
> Since Tomcat is the application in this case, Tomcat has to load them.
Firstly, you have to place the driver JAR in a place where it will be
accessible by your webapp. It can be either ./WEB-INF/lib/ (making
PostgreSQL driver available only to your webapp) or
${CATALINA_HOME}/common/lib/ (making it available to both Tomcat and all
web-apps) For loading the driver, you have two, possibly three options.
>
> 1. You'll load them yourself
>
> In a JSP or a Servlet you'll initialize PostgreSQL driver. The best place
for that is the "init()" method, where you'll place a line:
>
> Class.forName( "org.postgresql.Driver" );
>
> And then just anywhere in your code (OK, not exactly anywhere, Statement
and ResultSet must be kept inside "service()" method), just do:
>
> Connection conn = DriverManager.getConnection(
"jdbc:postgresql://host.domain.com/database", "user", "pass" );
> Statement stat = conn.createStatement();
> ResultSet rs = stat.executeQuery( myQuery );
>
> 2. You'll use the method above, but actual driver class, connection URL,
user and pass will be in the context parameters, making your actual code DB
independent.
>
> 3. You can use JNDI in Tomcat 4. This is described in JNDI-Howto-docs, but
I'm having problems getting it to work. People are chewing on the problem.
PostgreSQL and Tyrex in Tomcat are quarreling, it seams.
>
> The option 3 is the most correct one, since it strictly follows JEE
recommendations of application design.
>
> Nix.
>
From | Date | Subject | |
---|---|---|---|
Next Message | Nikola Milutinovic | 2002-03-21 09:42:51 | DataSource object ? |
Previous Message | Joe Shevland | 2002-03-21 04:27:03 | Re: more post & Tom (qu? ;) |