Skip to content

Failed to insert jdbc Timestamp using postgres jdbc java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp, java.util.Calendar) method #7253

@donothangbagsfromthehandlebar

Description

What type of bug is this?

Unexpected error

What subsystems are affected?

Write Protocols

Minimal reproduce step

  1. Create table
create table if not exists jdbc_insert (
    LOGGED_TIME timestamp not null,
    ORIGINAL_TIME timestamp,
    LOG_CATEGORY varchar(30) INVERTED INDEX,
    LOG_ACTION varchar(30) INVERTED INDEX,
    SUCCESS boolean,
    TIME INDEX (ORIGINAL_TIME)   
) with ('append_mode'='true');
  1. Run the following java program using 42.7.8 postgres jdbc driver and java 21.0.9+10
    String url = "jdbc:postgresql://localhost:4003/public";
    Connection conn = DriverManager.getConnection(url);

    TimeZone timeZone = TimeZone.getTimeZone("UTC");
    Calendar cal = Calendar.getInstance(timeZone);

    // conn = m_dataSource.getConnection();

    String insert = """
      INSERT INTO jdbc_insert (LOGGED_TIME, ORIGINAL_TIME, LOG_CATEGORY, LOG_ACTION, SUCCESS)
      VALUES(now() at time zone 'utc',?,?,?,?)
      """;

    PreparedStatement stmt = conn.prepareStatement(insert);

    stmt.setTimestamp(1, new Timestamp(System.currentTimeMillis()), cal);
    // stmt.setLong(1, System.currentTimeMillis());
    stmt.setString(2, "category1");
    stmt.setString(3, "action1");
    stmt.setBoolean(4, true);
    stmt.addBatch();

    stmt.executeBatch();

What did you expect to see?

A successfully inserted row in specified table.

Note that using the using http://localhost:4000/dashboard/#/dashboard/query and using the insert statement from the error below it works as expected.

INSERT INTO jdbc_insert (LOGGED_TIME, ORIGINAL_TIME, LOG_CATEGORY, LOG_ACTION, SUCCESS)
VALUES(now() at time zone 'utc',('2025-11-18 10:04:15.081+00'),('category1'),('action1'),('TRUE'::boolean))

What did you see instead?

java.sql.BatchUpdateException: Batch entry 0 INSERT INTO jdbc_insert (LOGGED_TIME, ORIGINAL_TIME, LOG_CATEGORY, LOG_ACTION, SUCCESS)
VALUES(now() at time zone 'utc',('2025-11-18 10:04:15.081+00'),('category1'),('action1'),('TRUE'::boolean))
 was aborted: ERROR: unsupported_parameter_value
  Detail: Found type: unknown  Call getNextException to see other errors in the batch.

	at org.postgresql.jdbc.BatchResultHandler.handleCompletion(BatchResultHandler.java:186)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:591)
	at org.postgresql.jdbc.PgStatement.internalExecuteBatch(PgStatement.java:891)
	at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:915)
	at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1778)
	at Test.test(Test.java:209)
Caused by: org.postgresql.util.PSQLException: ERROR: unsupported_parameter_value
  Detail: Found type: unknown
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2736)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2421)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:580)
	... 29 more

What operating system did you use?

Linux greptimedb-standalone-0 6.6.104.2-4.azl3 #1 SMP PREEMPT_DYNAMIC Tue Oct 21 20:44:14 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

What version of GreptimeDB did you use?

greptime branch: commit: 8153068 clean: true version: 1.0.0-beta.1

Relevant log output and stack trace

Metadata

Metadata

Assignees

Labels

C-bugCategory Bugs

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions