Re: Right version of jdbc

From: Raivo Rebane <raivore55(at)gmail(dot)com>
To: Ron <ronljohnsonjr(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Right version of jdbc
Date: 2023-09-29 09:05:10
Message-ID: CAMH5fpu8i2C94Whwcx7t-K3a0d6khFziThxNXa8OvLZ=LOjvrg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 <ronljohnsonjr(at)gmail(dot)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.
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dave Cramer 2023-09-29 11:05:35 Re: Right version of jdbc
Previous Message Vladimir Sitnikov 2023-09-29 06:46:46 Re: [EXT] YNT: Need help tuning a query