From: | Sylvain Leroux <sl20(at)wanadoo(dot)fr> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Using BigInteger as argument to AbstractJdbc2Statement.setObject |
Date: | 2009-08-06 13:49:07 |
Message-ID: | 4A7ADF53.2070203@wanadoo.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
> So my concern with mapping Jython integer value -> BigInteger -> NUMERIC
> is that you end up with a statement parameter that's not actually an
> integer, and so "stmt.setObject(1,1234567899999)" will fail in cases
> where you would expect an integer value to work.
Ok, I understand.
>
> Selecting a target type based on the magnitude of the parameter value
> passed may work better; then at least you get obvious behavior for cases
> where the value can fit in an integer.
That's what I have done now: setBigInteger will choose the narrowest
integer representation. NUMERIC will still be used when no integer type
is wide enough to hold the value.
With this, I think we have coherent behavior between Jython and psql.
As a side note, MySQL JDBC Driver accepts BigInteger in a setObject call
too. But it takes less care of them, since they are simply mapped to
strings:
> public void setObject(int parameterIndex, Object parameterObj)
> throws SQLException {
> ...
> ...
> } else if (parameterObj instanceof BigInteger) {
> setString(parameterIndex, parameterObj.toString());
Sylvain
--
Website: http://www.chicoree.fr
Attachment | Content-Type | Size |
---|---|---|
pgjdbc-biginteger.patch | text/plain | 2.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | dmp | 2009-08-10 15:05:05 | Bytea Hex Format |
Previous Message | JUNG, Christian | 2009-08-05 15:53:17 | PATCH: SET ROLE as connection parameter |