Google Группы больше не поддерживают новые публикации и подписки в сети Usenet. Опубликованный ранее контент останется доступен.

[JDBC] Bug: SimpleParameterList and resolved types

7 просмотров
Перейти к первому непрочитанному сообщению

Bruno De Fraine

не прочитано,
7 мая 2010 г., 08:15:0507.05.2010
Hello,

I'm experiencing a problem with a new version of the PostgreSQL JDBC driver. Under a condition that has got to do with the invocation of getMetaData(), the execution of a prepared statement raises an error "Can't change resolved type for param: 1 from 1043 to 25" (from SimpleParameterList) for (what seems to me) a perfectly valid insert statement.

I've created a simple test case to reproduce the bug. I use the following database:

CREATE DATABASE bug;

\connect bug

CREATE TABLE foo (
id serial PRIMARY KEY,
value text NOT NULL,
date timestamp DEFAULT now() NOT NULL
);

The test case (in attachment) will execute the following insert statement:

insert into foo(value,date) values (?,?) returning id

With the following result:

Driver version: PostgreSQL 8.4 JDBC4 (build 701)
Database version: PostgreSQL 8.4.3 on i386-apple-darwin9.7.0, compiled by GCC i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465), 32-bit
Exception in thread "main" java.lang.IllegalArgumentException: Can't change resolved type for param: 1 from 1043 to 25
at org.postgresql.core.v3.SimpleParameterList.setResolvedType(SimpleParameterList.java:230)
at org.postgresql.core.v3.QueryExecutorImpl.sendOneQuery(QueryExecutorImpl.java:1488)
at org.postgresql.core.v3.QueryExecutorImpl.sendQuery(QueryExecutorImpl.java:1062)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
at Bug.triggerBug(Bug.java:31)
at Bug.main(Bug.java:10)

I found that I can do three things to workaround this error at the moment:

1) Include a "prepare threshold" in the URL: jdbc:postgresql:bug?prepareThreshold=1
2) Comment out the call to ps.getMetaData() (but I need that in my actual app)
3) Use an older version of postgresql-jdbc; at least the following worked:

Driver version: PostgreSQL 8.3 JDBC3 with SSL (build 604)
Database version: PostgreSQL 8.4.3 on i386-apple-darwin9.7.0, compiled by GCC i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465), 32-bit
1

Best regards,
Bruno De Fraine

Bug.java

Kris Jurka

не прочитано,
7 мая 2010 г., 12:00:4907.05.2010

On Fri, 7 May 2010, Bruno De Fraine wrote:

> I'm experiencing a problem with a new version of the PostgreSQL JDBC

> driver.. Under a condition that has got to do with the invocation of

> getMetaData(), the execution of a prepared statement raises an error
> "Can't change resolved type for param: 1 from 1043 to 25" (from
> SimpleParameterList) for (what seems to me) a perfectly valid insert
> statement.

This has already been fixed in CVS. I guess it's been way too long since
I've put out a set of driver releases. I'll try to get to that this
weekend.

http://lists.pgfoundry.org/pipermail/jdbc-commits/2009-December/000219.html

Kris Jurka


--
Sent via pgsql-jdbc mailing list (pgsql...@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

0 новых сообщений