Re: Problem with DATE

Поиск
Список
Период
Сортировка
От Dave Cramer
Тема Re: Problem with DATE
Дата
Msg-id CADK3HHK0hvZ1sWgze7AsxwcGF+8aNWZHvCitkQ-aKHmmYyzPTA@mail.gmail.com
обсуждение исходный текст
Ответ на Problem with DATE  (Vinayak <vinpokale@gmail.com>)
Ответы Re: Problem with DATE  (Vinayak <vinpokale@gmail.com>)
Re: Problem with DATE  (Vinayak <vinpokale@gmail.com>)
Список pgsql-jdbc
Hi Vinayak,

Can you tell me which version of the driver you are using ?

Dave Cramer

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

On 6 January 2015 at 07:21, Vinayak <vinpokale@gmail.com> wrote:
Hi,
The following java code works fine using Oracle jdbc driver.
It works fine in PostgreSQL for BigDecimal and String etc. but for date it
throws error.

example:
ps = conn.prepareStatement("SELECT ?, ?, ?,?");
ps.setObject(1, new String("1.2"));
ps.setObject(2, new BigDecimal("1.2"));
ps.setObject(3, new String("2014-01-11 33:22:11"));
ps.setObject(4, Date.valueOf("2014-01-11"));

org.postgresql.util.PSQLException: ERROR: could not determine data type of
parameter $4
        at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2157)
        at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1886)
        at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:559)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
        at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:302)
        at TestSetDate.main(TestSetDate.java:39)

The above problem is solved after typecasting the 4th argument to date.
ps = conn.prepareStatement("SELECT ?, ?, ?,?::date");
OR
ps = conn.prepareStatement("SELECT ?, ?, ?,date(?)");

Is there any possibility to add something like PGdate in PostgreSQL jdbc
driver?
so that during migration from Oracle to PostgreSQL,there is no need to edit
the java code.

Regards,
Vinayak



-----
Regards,
Vinayak,

--
View this message in context: http://postgresql.nabble.com/Problem-with-DATE-tp5833008.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.


--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

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

Предыдущее
От: Vinayak
Дата:
Сообщение: Problem with DATE
Следующее
От: Lachezar Dobrev
Дата:
Сообщение: Re: Problem with DATE