Skip to content

Wrong timestamp returned by JDBC PreparedStatement for PostgreSQL v15 #1365

@ltbgogo

Description

@ltbgogo

Describe the problem
I got a wrong value which is "2000-01-01 00:00:00.0" after querying timestamp field for five times.
2024-08-30 10:40:38.622601
2024-08-30 10:40:38.622601
2024-08-30 10:40:38.622601
2024-08-30 10:40:38.622601
2024-08-30 10:40:38.622601
2000-01-01 00:00:00.0
2000-01-01 00:00:00.0
2000-01-01 00:00:00.0
2000-01-01 00:00:00.0
2000-01-01 00:00:00.0

To Reproduce

public static void main(String[] args) throws SQLException {
    try (Connection conn = DriverManager.getConnection(url, username, password)) {
        String sql = "select ctime from t_user limit 1";
        try (PreparedStatement stmt = conn.prepareStatement(sql)) {
            for (int i = 0; i < 10; i++) {
                try (ResultSet rs = stmt.executeQuery()) {
                    while (rs.next()) {
                        System.out.println(rs.getTimestamp("ctime"));
                    }
                }
            }
        }
    }
}

Expected behavior
2024-08-30 10:40:38.622601
2024-08-30 10:40:38.622601
2024-08-30 10:40:38.622601
2024-08-30 10:40:38.622601
2024-08-30 10:40:38.622601
2024-08-30 10:40:38.622601
2024-08-30 10:40:38.622601
2024-08-30 10:40:38.622601
2024-08-30 10:40:38.622601
2024-08-30 10:40:38.622601

Additional data / screenshots

create table if not exists t_user
(
    id   varchar(32),
    name varchar(255),
    ctime timestamp default CURRENT_TIMESTAMP
);
insert into t_user(id, name) values('11', 'tom');
insert into t_user(id, name) values('22', 'bobby');
insert into t_user(id, name) values('33', 'ana');

Environment

  • readysettech/readyset:stable-240523
  • docker
  • Postgres 15
  • JDBC, JDK17

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions