Re: Q: use setObject also for int or string
От
Kris Jurka
Тема
Re: Q: use setObject also for int or string
Дата
Msg-id
Pine.BSO.4.64.0809181939380.28127@leary.csoft.net
Ответ на
Q: use setObject also for int or string (Michael Enke)
Список
Дерево обсуждения
Q: use setObject also for int or string Michael Enke <michael.enke@wincor-nixdorf.com>
Re: Q: use setObject also for int or string Kris Jurka <books@ejurka.com>
On Thu, 18 Sep 2008, Michael Enke wrote: > in my application, queries with placeholder are created in a generic way > without knowing if the column is string or integer. It uses setString(1, > "1") even on int columns. > > In the thread "macaddr data type and prepared statements" I found that I > can use setObject(1, "1", Types.OTHER); and this works for me too. > > My question is if this is the "correct" way to continue (I can exchange > all the setString with setObject but I can not find out the datatype of > the columns in an easy way) or if this has drawbacks I do not see at the > moment. If you never have any type information, you can avoid changing all your setString calls by setting the connection URL property stringtype=unspecified [1]. setObject(..., Types.OTHER) is more useful when you have some type information. [1] http://jdbc.postgresql.org/documentation/83/connect.html#connection-parameters Kris Jurka
В списке pgsql-jdbc по дате отправления