Re: Inserting into time stamp columns

Поиск
Список
Период
Сортировка
От Dave Cramer
Тема Re: Inserting into time stamp columns
Дата
Msg-id CADK3HHJ74PGCFvOz=zOEjTmdmduA4xm3oeD65VUqg+kW-v5oEw@mail.gmail.com
обсуждение исходный текст
Ответ на Inserting into time stamp columns  (Péter Kovács <peter.dunay.kovacs@gmail.com>)
Ответы Re: Inserting into time stamp columns  (David Johnston <polobo@yahoo.com>)
Список pgsql-jdbc
This is more an artifact of the way bound parameters are handled by the backend. Normally we would bind this to a text type as it is a string. What you can do is try setting stringtype = unspecified as a connection parameter in which case it will let the server determine the type.



Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca


On Wed, Jun 26, 2013 at 10:39 AM, Péter Kovács <peter.dunay.kovacs@gmail.com> wrote:
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 по дате отправления:

Предыдущее
От: Péter Kovács
Дата:
Сообщение: Inserting into time stamp columns
Следующее
От: Dave Cramer
Дата:
Сообщение: Re: Inserting into time stamp columns