java.sql.BatchUpdateException with user-defined type when upgrading JDBC driver to version 9.3

From: Lisa Woodring <lisa(dot)woodring(at)iglass(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: java.sql.BatchUpdateException with user-defined type when upgrading JDBC driver to version 9.3
Date: 2015-03-13 15:13:37
Message-ID: CAHha=B4-yYYpE2UP4dXSV2Nohb0XgEPG1=DZAC2bjEk1v0QnCQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

We have a user-defined database type (that is essentially an enum). When
using any version of the JDBC driver, we can insert into that database
field with our normal operational code (which only does single inserts).

However, when using DBUnit with our test code, it performs a batch insert
into our test database for initialization of a test. In order to get this
to initially work with our user-defined type (back a couple of years ago),
we added a class that extends
"org.dbunit.ext.postgresql.PostgresqlDataTypeFactory" and overrides the
method "isEnumType". This was all that was needed to handle the
user-defined type.

But now with upgrading versions of the postgres JDBC driver, it does not
work. With changing only the JDBC driver, it breaks when moving from
version 9.2 to 9.3.
These versions work: 9.2-1004-jdbc4, 9.2-1004-jdbc41
These versions do NOT work: 9.3-1100-jdbc4, 9.3-1100-jdbc41,
9.4-1201-jdbc41

Any ideas on how to resolve this? Stack trace:

[junit] Caused by: org.dbunit.DatabaseUnitException: Exception
processing table name='FOO'
[junit] at
org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:231)
[junit] at
org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
[junit] at
org.unitils.dbunit.datasetloadstrategy.impl.CleanInsertLoadStrategy.doExecute(CleanInsertLoadStrategy.java:45)
[junit] at
org.unitils.dbunit.datasetloadstrategy.impl.BaseDataSetLoadStrategy.execute(BaseDataSetLoadStrategy.java:44)
[junit] ... 51 more
[junit] Caused by: java.sql.BatchUpdateException: Batch entry 0 insert
into "public"."FOO" ("fooid", "name", "desc", "parentfooid", "gtype")
values (999999, 'Virtual', 'Virtual Machines', 0, 'virtual') was aborted.
Call getNextException to see the cause.
[junit] at
org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2762)
[junit] at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1999)
[junit] at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:421)
[junit] at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2929)
[junit] at
org.dbunit.database.statement.PreparedBatchStatement.executeBatch(PreparedBatchStatement.java:86)
[junit] at
org.dbunit.database.statement.AutomaticPreparedBatchStatement.executeBatch(AutomaticPreparedBatchStatement.java:83)
[junit] at
org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:224)
[junit] ... 54 more

The offending column is "gtype" (and the batch insert works if I remove
setting this column). "gtype" is defined as follows:

Column | Type | Modifiers
---------+---------+--------------------------
gtype | vtype | default 'regular'::vtype

Schema | Name | Internal name | Size | Elements | Access privileges |
Description
--------+-------+---------------+------+-------------+-------------------+-------------
public | vtype | vtype | 4 | regular +| |
| | | | location +| |
| | | | restriction+| |
| | | | virtual | |

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2015-03-13 17:52:59 Re: java.sql.BatchUpdateException with user-defined type when upgrading JDBC driver to version 9.3
Previous Message Dave Cramer 2015-03-12 15:16:26 Re: [GENERAL] Problem JDBC, AutoCommit ON and SELECT FOR UPDATE