Inserting into time stamp columns - Mailing list pgsql-jdbc

From Péter Kovács
Subject Inserting into time stamp columns
Date
Msg-id CAO01x1FkfZCDvSfDuMDyJ9dUGnfiV5oBjvVOC9EOwQ06cmxckg@mail.gmail.com
Whole thread Raw
Responses Re: Inserting into time stamp columns  (Dave Cramer <pg@fastcrypt.com>)
List pgsql-jdbc
Hi,

Consider the following simple table:

create table tstest (ts timestamp);

The following code snippet

        PreparedStatement pstmt = connection.prepareStatement("insert into tstest values(?)");
        pstmt.setObject(1, "1998-06-04 00:00:00+09");
        pstmt.execute();

results in the following error: 

Exception in thread "main" org.postgresql.util.PSQLException: ERROR: column "ts" is of type timestamp without time zone but expression is of type character varying
  Hint: You will need to rewrite or cast the expression.

Do I understand it correctly that it is a limitation of the JDBC driver not to implement the String -> Timestamp implicit conversion listed in Table 8.5 of this document:
http://docs.oracle.com/javase/1.5.0/docs/guide/jdbc/getstart/mapping.html#1034737 ? Or is something missing in my code to get the friendly behavior of plain SQL which works with time stamp strings such as '1998-06-04 00:00:00+09 without explicit conversion?

Many thanks

Peter





pgsql-jdbc by date:

Previous
From: Kevin Carr
Date:
Subject: Re: JDBC 4 Compliance
Next
From: Dave Cramer
Date:
Subject: Re: Inserting into time stamp columns