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 <raivor...@gmail.com> 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 <davecramer@postgres.rocks> > wrote: > >> >> Dave Cramer >> www.postgres.rocks >> >> >> On Fri, 29 Sept 2023 at 06:19, Raivo Rebane <raivor...@gmail.com> 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 <ronljohnso...@gmail.com> 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 >> >