| From: | "Bert Hiri" <bert(at)openwiki(dot)com> |
|---|---|
| To: | pgsql-jdbc(at)postgresql(dot)org |
| Subject: | PreparedStatement.setString |
| Date: | 2005-04-22 06:44:07 |
| Message-ID: | 4150.82.94.255.26.1114152247.squirrel@webmail.high5.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-jdbc |
Hi,
Suppose I have a table like:
CREATE TABLE test
( id DECIMAL(10)
);
When executing the following statement from the psql command prompt:
INSERT INTO test(id) VALUES ('12345');
That will succeed.
When executing the following from JDBC:
PreparedStatement stmt =
con.prepareStatement("INSERT INTO test(id) VALUES (?)");
stmt.setString("12345");
stmt.executeUpdate();
This will fail. With the message:
Cause: ERROR: column "id" is of type numeric but expression is of type
character varying
I think this shouldn't fail. This exact same piece of Java code does work
with all other databases that I work with. And psql doesn't seem to mind
taking a string value either, so why should the PreparedStatement?
Regards,
Bert
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Oliver Jowett | 2005-04-22 08:12:37 | Re: PreparedStatement.setString |
| Previous Message | Dave Cramer | 2005-04-21 22:43:10 | Re: What Hibernate Object ID generator is recommanded for |