Re: DatabaseMetaData and Transactions
От | Mark Lewis |
---|---|
Тема | Re: DatabaseMetaData and Transactions |
Дата | |
Msg-id | 1118168193.24149.7.camel@archimedes.mirlogic.com обсуждение исходный текст |
Ответ на | Re: DatabaseMetaData and Transactions (Carl Olivier <carl@zero-one.co.za>) |
Список | pgsql-jdbc |
You can work around this problem by disabling the V3 protocol, which is by default used when communicating with newer servers. This is a performance hit because the V3 protocol is faster than V2, but shouldn't be too bad. See docs here: http://jdbc.postgresql.org/documentation/head/connect.html#connection- parameters -- Mark Lewis On Tue, 2005-06-07 at 12:54 +0200, Carl Olivier wrote: ... > In 7.3 (using the 7.3 JDBC driver) we were able to do the following: > > === SNIP === > > if (value == null) > { > stmt.setString( index, null ); > } > > === END === > > Some context here. We have a method that constructs a PreparedStatement > taking the sql (eg): > > UPDATE table SET cola = ?, colb = ?, colc = ? > > Or > > INSERT INTO table (cola, colb, colc) VALUES (?, ?, ?) > > And an Object[] of values (in the correct order) for the sql being used in > the PreparedStatement. > > Now - the reason we do a setString(index, null) and not a setNull(index, > Types.SOME_TYPE) is because this method is generic and does not always KNOW > the datatypes for the columns. > > Now, using PostgreSQL 8 (and the new JDBC driver for 8) we ARE still able to > do that when using a 7..3 db server, but get the following error when using > a version 8 PGSQL server: > > ERROR: column "created_by" is of type integer but expression is of type > character varying > > Where created_by is being passed a NULL value (using the setString(index, > null) method). > > Does anyone have any comments/suggestions/etc? Is there any way to get > around this? Or will we need to update our side to always pass in the > column meta data etc for use? > ...
В списке pgsql-jdbc по дате отправления: