JDBC Prepared Statement Bug
JDBC Prepared Statement Bug
От:
Dave <dave@candata.com>
Дата:
I am trying to use a Prepared Statement that has a character type. The value I am trying to use is '\0' and it is getting set with the setObject method. It looks like this is just getting converted to a string which the backend is taking as an end of command so the insert fails. I think for the chaacter type we need to check for this case and convert it to a string of "\0". I am using 7.2 and the JDBC driver that comes with it.
Re: JDBC Prepared Statement Bug
От:
Doug McNaught <doug@wireboard.com>
Дата:
Dave writes:
> I am trying to use a Prepared Statement that has a character type. The
> value I am trying to use is '\0' and it is getting set with the
> setObject method.
'\0' is not a legal value for character types. You'll need to use the
BYTEA type instead and quote it properly.
-Doug
--
Doug McNaught Wireboard Industries http://www.wireboard.com/
Custom software development, systems and network consulting.
Java PostgreSQL Enhydra Python Zope Perl Apache Linux BSD...
Re: JDBC Prepared Statement Bug
От:
Doug McNaught <doug@wireboard.com>
Дата:
Dave Smith writes:
> Well it is actually coded as '\u0000' which is valid value for a
> character type. The 'C' backend takes this as '\0' and and end of line
> terminator.
Hmmm, I don't know all the ins and outs of the i18n stuff, but you
should probably be storing strings as UTF-8 if you expect PG to handle
them as character data. The String.getBytes(String enc) call should
do it.
-Doug
--
Doug McNaught Wireboard Industries http://www.wireboard.com/
Custom software development, systems and network consulting.
Java PostgreSQL Enhydra Python Zope Perl Apache Linux BSD...
Re: JDBC Prepared Statement Bug
От:
Dave Smith <dave.smith@candata.com>
Дата:
Well it is actually coded as '\u0000' which is valid value for a character type. The 'C' backend takes this as '\0' and and end of line terminator. Doug McNaught wrote: > Dave writes: > > >>I am trying to use a Prepared Statement that has a character type. The >>value I am trying to use is '\0' and it is getting set with the >>setObject method. > > > '\0' is not a legal value for character types. You'll need to use the > BYTEA type instead and quote it properly. > > -Doug