Re: Right version of jdbc - Mailing list pgsql-general
From | Dave Cramer |
---|---|
Subject | Re: Right version of jdbc |
Date | |
Msg-id | CADK3HH+-rJjt=rb4q_fBURiq3sKdze4dXPv-0s3SQaXYpVxWsA@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 |
Dave Cramer
www.postgres.rocks
On Fri, 29 Sept 2023 at 06:19, Raivo Rebane <raivore55@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/APIexperimentMay be somebody can help me to solve the problem ?RaivoOn Fri, Sep 29, 2023 at 6:44 AM Ron <ronljohnsonjr@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
pgsql-general by date: