Re: Problem with DATE

Поиск
Список
Период
Сортировка
От dmp
Тема Re: Problem with DATE
Дата
Msg-id 54B9433B.6070706@ttc-cmc.net
обсуждение исходный текст
Ответ на Re: Problem with DATE  (Vinayak <vinpokale@gmail.com>)
Ответы Re: Problem with DATE  (Vinayak <vinpokale@gmail.com>)
Список pgsql-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


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: Problem with DATE
Следующее
От: Scott Morgan
Дата:
Сообщение: Docs java 1.7 and 1.8