From: dmp <danap@ttc-cmc.net>
To: Vinayak <vinpokale@gmail.com>
To: PostgreSQL JDBC <pgsql-jdbc@postgresql.org>
Subject: Re: Problem with DATE
Date: Fri, 16 Jan 2015 09:58:35 -0700
Message-ID: <54B9433B.6070706@ttc-cmc.net> (raw)
In-Reply-To: <1421386506791-5834215.post@n5.nabble.com>
References: <1420546864196-5833008.post@n5.nabble.com>
<CADK3HHK0hvZ1sWgze7AsxwcGF+8aNWZHvCitkQ-aKHmmYyzPTA@mail.gmail.com>
<1421061400959-5833623.post@n5.nabble.com>
<CADK3HHK5cWLDZCigT_WTg=KZB+r84_8CprjzZzH7WMvZ7FRCjw@mail.gmail.com>
<1421123270940-5833702.post@n5.nabble.com>
<1421131374401-5833708.post@n5.nabble.com>
<CADK3HHKogHhRauJ9w9Dr=H_qinbaZcc6v6ZLXYnAuaxLmLz0xg@mail.gmail.com>
<1421213697306-5833860.post@n5.nabble.com>
<CADK3HHLLUh3AiTqhVgWRfwoqXaj3hicMAg-SuD4X0qoMoRvbAw@mail.gmail.com>
<1421386506791-5834215.post@n5.nabble.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
Vinayak wrote:
> Hi Dave,
> Thank you for explanation.
>
> I understood that the behavior of date is different in PostgreSQL and Java.
> PostgreSQL DATE type return date part only.
> Java DATE return date and time with timezone.
>> I am guessing what you really want is to just take the date in your Oracle
> db, load it into java and store >it into postgresql without any
> transformation.
>> This would require a custom date type.
> I have created custom date type which return date and time in PostgreSQL.
> postgres=# select now()::date;
> now
> ---------------------------------
> 2015-01-16 10:51:41
> (1 row)
> but still PreparedStatement throws error for date parameter.
>
> -----
> Regards,
> Vinayak,
Hello,
If you are able to perform the conversion of the Oracle Date to a java.sql.Date
type then perhaps instead of trying to force this into a setObject() statement
have you just tried setDate()?
The code you have shown works fine with my application, but not as setObject()
if (columnType.equals("DATE"))
{
java.sql.Date dateValue;
dateString = MyJSQLView_Utils.convertViewDateString_To_DBDateString(
dateTimeFormString,DBTablesPanel.getGeneralDBProperties().getViewDateFormat());
dateValue = java.sql.Date.valueOf(dateString);
prepared_sqlStatement.setDate(i++, dateValue);
}
I know you have said that you do not wish to change your code throughout, but
this may be the easist approach rather then rewriting the driver. You might
have already changed the code in a day's work.
danap.
MyJSQLView Project Manager
dandymadeproductions.com
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: danap@ttc-cmc.net, vinpokale@gmail.com
Subject: Re: Problem with DATE
In-Reply-To: <54B9433B.6070706@ttc-cmc.net>
References: <1420546864196-5833008.post@n5.nabble.com> <CADK3HHK0hvZ1sWgze7AsxwcGF+8aNWZHvCitkQ-aKHmmYyzPTA@mail.gmail.com> <1421061400959-5833623.post@n5.nabble.com> <CADK3HHK5cWLDZCigT_WTg=KZB+r84_8CprjzZzH7WMvZ7FRCjw@mail.gmail.com> <1421123270940-5833702.post@n5.nabble.com> <1421131374401-5833708.post@n5.nabble.com> <CADK3HHKogHhRauJ9w9Dr=H_qinbaZcc6v6ZLXYnAuaxLmLz0xg@mail.gmail.com> <1421213697306-5833860.post@n5.nabble.com> <CADK3HHLLUh3AiTqhVgWRfwoqXaj3hicMAg-SuD4X0qoMoRvbAw@mail.gmail.com> <1421386506791-5834215.post@n5.nabble.com> <54B9433B.6070706@ttc-cmc.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox