Re: Right version of jdbc - Mailing list pgsql-general

From Raivo Rebane
Subject Re: Right version of jdbc
Date
Msg-id CAMH5fpuwfZLbpCd=kFO=039N+88A9oxa-=WC6pT9SQQ3ZJg+Rg@mail.gmail.com
Whole thread Raw
In response to Re: Right version of jdbc  (Raivo Rebane <raivore55@gmail.com>)
Responses Re: Right version of jdbc
List pgsql-general
Sorry. I accidentally usin postgres 16, which was empty
Many thanks for advise !!!

Raivo

On Sat, Sep 30, 2023 at 8:18 AM Raivo Rebane <raivore55@gmail.com> wrote:
May be I have to copy PostGis draiver also to tomcat/lib ?

Raivo

On Sat, Sep 30, 2023 at 8:01 AM Raivo Rebane <raivore55@gmail.com> wrote:
Hi,
I copied the postgres driver to Tomcat/lib.
PS C:\Program Files\Apache Software Foundation\Tomcat 9.0\lib> dir post*
    Directory: C:\Program Files\Apache Software Foundation\Tomcat 9.0\lib
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        28.09.2023     14:40        1081604 postgresql-42.6.0.jar
but Tomcat remains to give error -
java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/mushroom_database
I am using Postgres 15. May be I have to use more older one ?
 

Raivo

On Sat, Sep 30, 2023 at 6:32 AM Craig McIlwee <craigm@vt.edu> wrote:
> for some reason the postgresql jar is not in the classpath.

This is due to the way that Tomcat loads drivers, which is documented at [1].  In short, the JDBC driver should be placed in the tomcat/lib directory and removed from the application's WEB-INF/lib directory.  After doing that, I was able to get past the "No suitable driver" exception.

OP, you should read that entire page, and in particular the portion at [2].  By registering a "Resource" with Tomcat, you can let it manage a connection pool for you (if you aren't already using something like PgBouncer or pgpool) and, if registered at the container level, in the future you can share that pool across all of your web applications in the container.


Craig

pgsql-general by date:

Previous
From: Raivo Rebane
Date:
Subject: Re: Right version of jdbc
Next
From: James Healy
Date:
Subject: Gradual migration from integer to bigint?