Re: Right version of jdbc
Hi, The code is : package MushroomAPIs; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; @WebServlet("/AddMushrooms") public class AddMushrooms extends HttpServlet implements java.io.Serializable { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String DB_URL = "jdbc:postgresql://localhost:5432/mushroom_database"; final String USER = "mushroomer"; final String PASSWORD = ""; Connection connection = null; Timestamp LastModifiedTS = Timestamp.valueOf("1970-01-01 00:00:00"); try { connection = DriverManager.getConnection(DB_URL, USER, PASSWORD); // SQL päring vanima timestamp-i leidmiseks String query = "SELECT timestamp AS oldest_timestamp FROM mushrooms"; PreparedStatement statement = connection.prepareStatement(query); ResultSet resultSet = statement.executeQuery(); while (resultSet.next()) { Timestamp oldest_timestamp = resultSet.getTimestamp("oldest_timestamp"); if (oldest_timestamp.after(LastModifiedTS)) LastModifiedTS = oldest_timestamp; } System.out.println("Vanim timestamp: " + LastModifiedTS); } catch (SQLException e) { e.printStackTrace(); } int count = ProcAddMushrooms.GetAddMushrooms(connection, LastModifiedTS); response.getWriter().println("Added " + count + " mushrooms"); } } and available from github - https://github.com/raaivore/APIexperiment May be somebody can help me to solve the problem ? Raivo On Fri, Sep 29, 2023 at 6:44 AM Ron wrote: > On 9/28/23 01:18, Raivo Rebane wrote: > > [snip] > > I made a new Java application Eclipse Dynamic WEB application and want to > use Postgres - PostgreSQL 10.14 > > [snip] > > What's wrong. Or is better to use more newer postgres. And then which > jdbc-I need to use ? > > > https://www.postgresql.org/support/versioning/ > > Pg 10 will be EOL in *6 weeks*. Thus, "yes, use a newer version of > Postgresql" (unless, like me, you're constrained by circumstances like "the > business won't let us upgrade"). > > Pg 15 and the latest JDBC are in the repositories: > https://www.postgresql.org/download/ > > -- > Born in Arizona, moved to Babylonia. >
Re: Right version of jdbc
Dave Cramer www.postgres.rocks On Fri, 29 Sept 2023 at 06:19, Raivo Rebane wrote: > Hi, > > The code is : > package MushroomAPIs; > > import java.io.IOException; > import javax.servlet.ServletException; > import javax.servlet.annotation.WebServlet; > import javax.servlet.http.HttpServlet; > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpServletResponse; > > import java.sql.Connection; > import java.sql.DriverManager; > import java.sql.PreparedStatement; > import java.sql.ResultSet; > import java.sql.SQLException; > import java.sql.Timestamp; > > @WebServlet("/AddMushrooms") > public class AddMushrooms extends HttpServlet implements > java.io.Serializable { > protected void doGet(HttpServletRequest request, HttpServletResponse > response) > throws ServletException, IOException { > > final String DB_URL = "jdbc:postgresql://localhost:5432/mushroom_database"; > final String USER = "mushroomer"; > final String PASSWORD = ""; > > Connection connection = null; > Timestamp LastModifiedTS = Timestamp.valueOf("1970-01-01 00:00:00"); > > try { > connection = DriverManager.getConnection(DB_URL, USER, PASSWORD); > > // SQL päring vanima timestamp-i leidmiseks > String query = "SELECT timestamp AS oldest_timestamp FROM mushrooms"; > PreparedStatement statement = connection.prepareStatement(query); > ResultSet resultSet = statement.executeQuery(); > > while (resultSet.next()) { > Timestamp oldest_timestamp = resultSet.getTimestamp("oldest_timestamp"); > if (oldest_timestamp.after(LastModifiedTS)) > LastModifiedTS = oldest_timestamp; > } > System.out.println("Vanim timestamp: " + LastModifiedTS); > > } catch (SQLException e) { > e.printStackTrace(); > } > > int count = ProcAddMushrooms.GetAddMushrooms(connection, LastModifiedTS); > > response.getWriter().println("Added " + count + " mushrooms"); > } > } > and available from github - https://github.com/raaivore/APIexperiment > > May be somebody can help me to solve the problem ? > > Raivo > > On Fri, Sep 29, 2023 at 6:44 AM Ron wrote: > >> On 9/28/23 01:18, Raivo Rebane wrote: >> >> [snip] >> >> I made a new Java application Eclipse Dynamic WEB application and want to >> use Postgres - PostgreSQL 10.14 >> >> [snip] >> >> What's wrong. Or is better to use more newer postgres. And then which >> jdbc-I need to use ? >> >> >> https://www.postgresql.org/support/versioning/ >> >> Pg 10 will be EOL in *6 weeks*. Thus, "yes, use a newer version of >> Postgresql" (unless, like me, you're constrained by circumstances like "the >> business won't let us upgrade"). >> >> Pg 15 and the latest JDBC are in the repositories: >> https://www.postgresql.org/download/ >> > -- >> Born in Arizona, moved to Babylonia. >> > I loaded your project in IDEA and it was referring to jdk1.7 It also looks like you still have the postgis-geometry-2.5.0.jar in the webapp/lib dir remove it Dave
pg_agent jobs
Hello all members, here's my question: db version 14.5 we have to create a pg_agent job with 2 steps: 1_step execute query: if query result is true or find > 0 records then process next step, else it stops executing job 2_step execute batch command we tried to seta as 1_step the query: SELECT EXISTS (SELECT * FROM mytable WHERE someconditions) but even if it returns false 2_step is always executed. Need some help, thanks in advance, Giovanni -- best regards
Re: pg_agent jobs
On 9/29/23 08:55, Giovanni Biscontini wrote: Hello all members, here's my question: db version 14.5 we have to create a pg_agent job with 2 steps: 1_step execute query: if query result is true or find > 0 records then process next step, else it stops executing job 2_step execute batch command we tried to seta as 1_step the query: SELECT EXISTS (SELECT * FROM mytable WHERE someconditions) but even if it returns false 2_step is always executed. Need some help, thanks in advance, Giovanni The only thing I could see here: https://www.pgadmin.org/docs/pgadmin4/development/pgagent_jobs.html that might work is: " Use the On error drop-down to specify the behavior of pgAgent if it encounters an error while executing the step. Select from: Fail - Stop the job if you encounter an error while processing this step. Success - Mark the step as completing successfully, and continue. Ignore - Ignore the error, and continue. " So in the first step induce an error if the conditions are not met. -- best regards -- Adrian Klaver adrian.kla...@aklaver.com
Re: Right version of jdbc
Thanks, there was really JDK 17 in use. I changed it to Java 1.8 PS C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin> java -version java version "1.8.0_381" Java(TM) SE Runtime Environment (build 1.8.0_381-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.381-b09, mixed mode) but the same error occured : java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/mushroom_database at java.sql.DriverManager.getConnection(DriverManager.java:689) at java.sql.DriverManager.getConnection(DriverManager.java:247) at MushroomAPIs.AddMushrooms.doGet(AddMushrooms.java:30) why java.sql gives that error ? Raivo On Fri, Sep 29, 2023 at 4:03 PM Raivo Rebane wrote: > I removed this recommended jar. > I am using Eclipse and there Java 1.8 is setted. > What I have to do ? > > Raivo > > On Fri, Sep 29, 2023 at 2:05 PM Dave Cramer > wrote: > >> >> Dave Cramer >> www.postgres.rocks >> >> >> On Fri, 29 Sept 2023 at 06:19, Raivo Rebane wrote: >> >>> Hi, >>> >>> The code is : >>> package MushroomAPIs; >>> >>> import java.io.IOException; >>> import javax.servlet.ServletException; >>> import javax.servlet.annotation.WebServlet; >>> import javax.servlet.http.HttpServlet; >>> import javax.servlet.http.HttpServletRequest; >>> import javax.servlet.http.HttpServletResponse; >>> >>> import java.sql.Connection; >>> import java.sql.DriverManager; >>> import java.sql.PreparedStatement; >>> import java.sql.ResultSet; >>> import java.sql.SQLException; >>> import java.sql.Timestamp; >>> >>> @WebServlet("/AddMushrooms") >>> public class AddMushrooms extends HttpServlet implements >>> java.io.Serializable { >>> protected void doGet(HttpServletRequest request, HttpServletResponse >>> response) >>> throws ServletException, IOException { >>> >>> final String DB_URL = >>> "jdbc:postgresql://localhost:5432/mushroom_database"; >>> final String USER = "mushroomer"; >>> final String PASSWORD = ""; >>> >>> Connection connection = null; >>> Timestamp LastModifiedTS = Timestamp.valueOf("1970-01-01 00:00:00"); >>> >>> try { >>> connection = DriverManager.getConnection(DB_URL, USER, PASSWORD); >>> >>> // SQL päring vanima timestamp-i leidmiseks >>> String query = "SELECT timestamp AS oldest_timestamp FROM mushrooms"; >>> PreparedStatement statement = connection.prepareStatement(query); >>> ResultSet resultSet = statement.executeQuery(); >>> >>> while (resultSet.next()) { >>> Timestamp oldest_timestamp = resultSet.getTimestamp("oldest_timestamp"); >>> if (oldest_timestamp.after(LastModifiedTS)) >>> LastModifiedTS = oldest_timestamp; >>> } >>> System.out.println("Vanim timestamp: " + LastModifiedTS); >>> >>> } catch (SQLException e) { >>> e.printStackTrace(); >>> } >>> >>> int count = ProcAddMushrooms.GetAddMushrooms(connection, LastModifiedTS); >>> >>> response.getWriter().println("Added " + count + " mushrooms"); >>> } >>> } >>> and available from github - https://github.com/raaivore/APIexperiment >>> >>> May be somebody can help me to solve the problem ? >>> >>> Raivo >>> >>> On Fri, Sep 29, 2023 at 6:44 AM Ron wrote: >>> On 9/28/23 01:18, Raivo Rebane wrote: [snip] I made a new Java application Eclipse Dynamic WEB application and want to use Postgres - PostgreSQL 10.14 [snip] What's wrong. Or is better to use more newer postgres. And then which jdbc-I need to use ? https://www.postgresql.org/support/versioning/ Pg 10 will be EOL in *6 weeks*. Thus, "yes, use a newer version of Postgresql" (unless, like me, you're constrained by circumstances like "the business won't let us upgrade"). Pg 15 and the latest JDBC are in the repositories: https://www.postgresql.org/download/ >>> -- Born in Arizona, moved to Babylonia. >>> >> >> >> I loaded your project in IDEA and it was referring to jdk1.7 >> It also looks like you still have the postgis-geometry-2.5.0.jar in the >> webapp/lib dir remove it >> >> Dave >> >
Re: Right version of jdbc
On Fri, 29 Sept 2023 at 14:22, Raivo Rebane wrote: > Thanks, > > there was really JDK 17 in use. > I changed it to Java 1.8 > PS C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin> java > -version > java version "1.8.0_381" > Java(TM) SE Runtime Environment (build 1.8.0_381-b09) > Java HotSpot(TM) 64-Bit Server VM (build 25.381-b09, mixed mode) > > but the same error occured : > java.sql.SQLException: No suitable driver found for > jdbc:postgresql://localhost:5432/mushroom_database > at java.sql.DriverManager.getConnection(DriverManager.java:689) > at java.sql.DriverManager.getConnection(DriverManager.java:247) > at MushroomAPIs.AddMushrooms.doGet(AddMushrooms.java:30) > why java.sql gives that error ? > for some reason the postgresql jar is not in the classpath. Dave >
Re: Right version of jdbc
Am 29.09.23 um 20:42 schrieb Dave Cramer: On Fri, 29 Sept 2023 at 14:22, Raivo Rebane wrote: Thanks, there was really JDK 17 in use. I changed it to Java 1.8 PS C:\Program Files\Apache Software Foundation\Tomcat 9.0\bin> java -version java version "1.8.0_381" Java(TM) SE Runtime Environment (build 1.8.0_381-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.381-b09, mixed mode) but the same error occured : java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/mushroom_database at java.sql.DriverManager.getConnection(DriverManager.java:689) at java.sql.DriverManager.getConnection(DriverManager.java:247) at MushroomAPIs.AddMushrooms.doGet(AddMushrooms.java:30) why java.sql gives that error ? for some reason the postgresql jar is not in the classpath. Dave try to call "Class.forName("org.postgresql.Driver");" before "connection = DriverManager.getConnection(DB_URL, USER, PASSWORD);" i had some issues with getConnection() some time ago and this was the solution. no idea why.
cache lookup failed for function 0
Hi, select version(); PostgreSQL 15.4 on x86_64-mageia-linux-gnu, compiled by gcc (Mageia 12.3.0-3.mga9) 12.3.0, 64-bit As a test, rather than use INSERT, I recently wrote a python test script to import some 8M & 33M record files with COPY instead. These worked with last weekend's data dump. Next, I wanted to look into importing a subset of columns using the below logic; but I'm getting "ERROR: cache lookup failed for function 0". Re-running the same full imports that worked Saturday, I now get the same error. Could something in the DB cause this "function" error? Simplified statements; just trying to import a subset of columns: DROP TABLE IF EXISTS t; CREATE TABLE IF NOT EXISTS t ( f1 text, f2 text, f3 text, f4 text, f5 text ); COPY t ( -- import only a subset of columns f1, f3, f5 ) FROM '/tmp/foo.txt' WITH (FORMAT CSV, HEADER, DELIMITER ' ', ENCODING 'ISO-8859-1') ; ERROR: cache lookup failed for function 0 Where: COPY t, line 1 1 statement failed. "function"? Is this referring to an implied/internal function? Searching has not provided any clue, yet... There are no user functions in the database: ostgres=# \df List of functions Schema | Name | Result data type | Argument data types | Type +--+--+-+-- (0 rows) It feels like something changed since the previously working script no longer works... Clues? Thanks, Pierre
Re: Right version of jdbc
> 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. [1] https://tomcat.apache.org/tomcat-9.0-doc/jndi-datasource-examples-howto.html#DriverManager,_the_service_provider_mechanism_and_memory_leaks [2] https://tomcat.apache.org/tomcat-9.0-doc/jndi-datasource-examples-howto.html#PostgreSQL Craig >
Re: cache lookup failed for function 0
On 9/29/23 1:37 PM, p...@pfortin.com wrote: Hi, select version(); PostgreSQL 15.4 on x86_64-mageia-linux-gnu, compiled by gcc (Mageia 12.3.0-3.mga9) 12.3.0, 64-bit As a test, rather than use INSERT, I recently wrote a python test script to import some 8M & 33M record files with COPY instead. These worked with last weekend's data dump. Next, I wanted to look into importing a subset of columns using the below logic; but I'm getting "ERROR: cache lookup failed for function 0". Re-running the same full imports that worked Saturday, I now get the same error. Could something in the DB cause this "function" error? Simplified statements; just trying to import a subset of columns: DROP TABLE IF EXISTS t; CREATE TABLE IF NOT EXISTS t ( f1 text, f2 text, f3 text, f4 text, f5 text ); COPY t ( -- import only a subset of columns I'm going to say it is the ( -- import only a subset of columns I suspect the -- comment is the issue. You need to show the actual Python code for a more complete answer. f1, f3, f5 ) FROM '/tmp/foo.txt' WITH (FORMAT CSV, HEADER, DELIMITER ' ', ENCODING 'ISO-8859-1') ; ERROR: cache lookup failed for function 0 Where: COPY t, line 1 1 statement failed. "function"? Is this referring to an implied/internal function? Searching has not provided any clue, yet... There are no user functions in the database: ostgres=# \df List of functions Schema | Name | Result data type | Argument data types | Type +--+--+-+-- (0 rows) It feels like something changed since the previously working script no longer works... Clues? Thanks, Pierre
Re: cache lookup failed for function 0
p...@pfortin.com writes: > As a test, rather than use INSERT, I recently wrote a python test script > to import some 8M & 33M record files with COPY instead. These worked with > last weekend's data dump. Next, I wanted to look into importing a subset > of columns using the below logic; but I'm getting "ERROR: cache lookup > failed for function 0". Re-running the same full imports that worked > Saturday, I now get the same error. > Could something in the DB cause this "function" error? "cache lookup failed" certainly smells like a server internal error, but we'd have heard about it if the trivial case you show could reach such a problem. I'm thinking there's things you haven't told us. What extensions do you have installed? Maybe an event trigger? Also, the reference to ENCODING 'ISO-8859-1' makes me wonder what encoding conversion is being performed. regards, tom lane
Re: Right version of jdbc
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 - -- -a28.09.2023 14:401081604 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 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. > > [1] > https://tomcat.apache.org/tomcat-9.0-doc/jndi-datasource-examples-howto.html#DriverManager,_the_service_provider_mechanism_and_memory_leaks > [2] > https://tomcat.apache.org/tomcat-9.0-doc/jndi-datasource-examples-howto.html#PostgreSQL > > Craig > >>
Re: Right version of jdbc
May be I have to copy PostGis draiver also to tomcat/lib ? Raivo On Sat, Sep 30, 2023 at 8:01 AM Raivo Rebane 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 > - -- > -a28.09.2023 14:401081604 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 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. >> >> [1] >> https://tomcat.apache.org/tomcat-9.0-doc/jndi-datasource-examples-howto.html#DriverManager,_the_service_provider_mechanism_and_memory_leaks >> [2] >> https://tomcat.apache.org/tomcat-9.0-doc/jndi-datasource-examples-howto.html#PostgreSQL >> >> Craig >> >>>
Re: Right version of jdbc
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 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 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 >> - -- >> -a28.09.2023 14:401081604 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 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. >>> >>> [1] >>> https://tomcat.apache.org/tomcat-9.0-doc/jndi-datasource-examples-howto.html#DriverManager,_the_service_provider_mechanism_and_memory_leaks >>> [2] >>> https://tomcat.apache.org/tomcat-9.0-doc/jndi-datasource-examples-howto.html#PostgreSQL >>> >>> Craig >>>
Gradual migration from integer to bigint?
My organization has a number of very large tables (most 100s of GB, a couple over a Tb) that were created many years ago by a tool that defaulted to integer PKs rather than bigint. Those PKs have a number of integer FKs in related tables as well. We shouldn't have let them get so big, but that's a conversation for another day. Some are approaching overflow and we're slowly doing the work to migrate to bigint. Mostly via the well understood "add a new id_bigint column, populate on new tuples, backfill the old, switch the PK" method. The backfill is slow on these large tables, but it works and there's plenty of blog posts and documentation to follow. It did make me curious though: would it be possible for postgres to support gradual migration from integer to bigint in a more transparent way, where new and updated tuples are written as bigint, but existing tuples can be read as integer? I assume maybe a complication is that the catalog says the column is either 32bit int or 64bit bigint and making that conditional is hard. There's presumably other considerations I'm unaware of too. My core question: are there significant technical blockers to supporting this kind of gradual in place migration, or has it just not been enough of a problem that it's received attention? James
Re: Right version of jdbc
Hi, sometimes I am lucky and don't get the old error, but sometime not. I tried to use PreparedStatement, but I got error - org.postgresql.util.PSQLException: Can't use query methods that take a query string on a PreparedStatement. at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:145) at MushroomAPIs.Clean.deleteAllRecordsFromTable(Clean.java:34) and java code is - String deleteQuery = "DELETE FROM " + tableNam System.out.println(deleteQuery); PreparedStatement statement = connection.prepareStatement(deleteQuery); May be it's easy for me to use normal statement ? Raivo On Sat, Sep 30, 2023 at 8:27 AM Raivo Rebane wrote: > 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 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 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 >>> - -- >>> -a28.09.2023 14:401081604 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 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. [1] https://tomcat.apache.org/tomcat-9.0-doc/jndi-datasource-examples-howto.html#DriverManager,_the_service_provider_mechanism_and_memory_leaks [2] https://tomcat.apache.org/tomcat-9.0-doc/jndi-datasource-examples-howto.html#PostgreSQL Craig >