Re: tomcat +postgres THANKS
| От | Gonzalo Aranda |
|---|---|
| Тема | Re: tomcat +postgres THANKS |
| Дата | |
| Msg-id | 000001c1d0b8$2113f340$b21ba8c0@wksagus обсуждение исходный текст |
| Ответ на | tomcat +postgres ("Gonzalo Aranda" <garanda@bitakora.com>) |
| Список | 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.Milutinovic@ev.co.yu>
To: "Gonzalo Aranda" <garanda@bitakora.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.
>
В списке pgsql-jdbc по дате отправления: