Re: BUG #5948: JDBC wrond insert of timestamp data

From: Kris Jurka <books(at)ejurka(dot)com>
To: "yuriy(dot)tereschuk" <astro(at)evernet(dot)lutsk(dot)ua>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5948: JDBC wrond insert of timestamp data
Date: 2011-03-25 15:00:31
Message-ID: alpine.BSO.2.00.1103251055350.9510@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, 25 Mar 2011, yuriy.tereschuk wrote:

>
> The following bug has been logged online:
>
> Bug reference: 5948
> PostgreSQL version: postgresql90
> Operating system: Linux Fedora 14
> Description: JDBC wrond insert of timestamp data
> Details:
>
> org.postgresql.util.PSQLException: ERROR: column "datetime" is of type
> timestamp without time zone but expression is of type character varying
> Hint: You will need to rewrite or cast the expression.
>
> JDBC version postgresql90-jdbc-9.0.801-1PGDG.f14.i686
>

You are most likely setting the timestamp value by using setString or
setObject with a string value on a PreparedStatement. This is indicating
to the driver that you want the parameter to have a string (varchar) type.
This is not correct for a timestamp. You should use setTimestamp or
setObject with a third parameter indicating that the value is a timestamp.
If you are unable to change your application for some reason, you can
adjust the driver's binding behavior by using the stringtype=unspecified
connection parameter described here:

http://jdbc.postgresql.org/documentation/84/connect.html#connection-parameters

Kris Jurka

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2011-03-25 15:17:19 Re: BUG #5946: Long exclusive lock taken by vacuum (not full)
Previous Message Alvaro Herrera 2011-03-25 14:16:08 Re: BUG #5946: Long exclusive lock taken by vacuum (not full)