pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: j.random.programmer <javadesigner@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: Possible to say: [setObject("123")] to insert into int column type ?
Date: Wed, 28 Jun 2006 15:46:05 -0700 (PDT)
Message-ID: <20060628224605.94631.qmail@web32014.mail.mud.yahoo.com> (raw)

Hi:

I think setObject() has been discussed extensively on
this list 
(particularly with setting null values). However,
consider the following:

In PSQL:
	test=# create table foo (number_column int);

Now in Java:
	PreparedStatement ps = con.prepareStatement(
		"insert into foo (number_column) values (?)"
		);
	ps.setObject(1, "123");
	ps.executeUpdate();

This will throw a Driver exception. Is this expected
behavior 
or should the driver do a Integer.parseInt(...) on the
string value 
as needed ? 

This is not a show-stopper or even a serious bug in my
code
and is easy to workaround. I'm just curious as to the
"right"
behavior as per the JDBC spec.....

Best regards,
--j

----------------------- Exception ------------------

ERROR: column "number_column" is of type integer but 
expression is of type character varying
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(
 QueryExecutorImpl.java:1527)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(
 QueryExecutorImpl.java:1311)
.....
---------------------------------------------------


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



view thread (2+ messages)  latest in thread

Message-ID: <20060628224605.94631.qmail@web32014.mail.mud.yahoo.com>
Permalink:  ../20060628224605.94631.qmail@web32014.mail.mud.yahoo.com/
Also on:    postgresql.org/message-id/20060628224605.94631.qmail@web32014.mail.mud.yahoo.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: javadesigner@yahoo.com
  Subject: Re: Possible to say: [setObject("123")] to insert into int column type ?
  In-Reply-To: <20060628224605.94631.qmail@web32014.mail.mud.yahoo.com>
  References: <20060628224605.94631.qmail@web32014.mail.mud.yahoo.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