pg.ddx.io pgsql-jdbc@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Vinayak <vinpokale@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: Problem with DATE
Date: Tue, 6 Jan 2015 05:21:04 -0700 (MST)
Message-ID: <1420546864196-5833008.post@n5.nabble.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
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
view thread (20+ messages) latest in thread
Message-ID: <1420546864196-5833008.post@n5.nabble.com> Permalink: ../1420546864196-5833008.post@n5.nabble.com/ Also on: postgresql.org/message-id/1420546864196-5833008.post@n5.nabble.com ·
reply
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: vinpokale@gmail.com Subject: Re: Problem with DATE In-Reply-To: <1420546864196-5833008.post@n5.nabble.com> References: <1420546864196-5833008.post@n5.nabble.com> * 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