Skip site navigation (1) Skip section navigation (2)

Re: Batch INSERT failing with error 22P02

From: Eric Faulhaber <ecf(at)goldencode(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Batch INSERT failing with error 22P02
Date: 2007-09-20 18:49:24
Message-ID: 46F2C0B4.1060306@goldencode.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
Kris Jurka wrote:
> 2) Where's the unspecified type coming from?  I've put in a hack to 
> the driver to throw an exception when the first unspecified type is 
> set which should hopefully provide enough information to track it back 
> to your application.  Unspecified types are perfectly legal, so this 
> isn't a real problem, but it may be informational.

I turned on some additional logging in our code to see what data is 
being bound to each parameter in our UserType implementation.  It seems 
the unspecified type is coming from a Date object bound with 
PreparedStatement.setDate(int, java.sql.Date).  At least, this is the 
first parameter that triggers the test.

...
Sep 20, 2007 2:30:04 PM 
com.goldencode.p2j.persist.AbstractWrapperUserType nullSafeSet
FINEST: binding '11/30/04' to parameter: 9
Sep 20, 2007 2:30:04 PM com.goldencode.p2j.schema.ImportWorker$Library 
importTable
SEVERE: Error processing import data from 
/home/ecf/dump/export/gso/turnarnd.d;  100 of ? record(s) successfully 
processed;  0 record(s) uncommitted due to this error;  0 record(s) dropped
java.lang.IllegalArgumentException: Unspecified type comes from here, 
parameter: 9
        at 
org.postgresql.core.v3.SimpleParameterList.bind(SimpleParameterList.java:68)
        at 
org.postgresql.core.v3.SimpleParameterList.setStringParameter(SimpleParameterList.java:120)
        at 
org.postgresql.jdbc2.AbstractJdbc2Statement.bindString(AbstractJdbc2Statement.java:2119)
        at 
org.postgresql.jdbc2.AbstractJdbc2Statement.setDate(AbstractJdbc2Statement.java:3015)
        at 
org.postgresql.jdbc2.AbstractJdbc2Statement.setDate(AbstractJdbc2Statement.java:1296)
        at 
com.goldencode.p2j.persist.DateUserType.bindNonNull(DateUserType.java:159)
        at 
com.goldencode.p2j.persist.AbstractWrapperUserType.nullSafeSet(AbstractWrapperUserType.java:263)
        at 
com.goldencode.p2j.persist.DateUserType.nullSafeSet(DateUserType.java:39)
        at org.hibernate.type.CustomType.nullSafeSet(CustomType.java:141)
        at 
org.hibernate.persister.entity.BasicEntityPersister.dehydrate(BasicEntityPersister.java:1617)
        at 
org.hibernate.persister.entity.BasicEntityPersister.dehydrate(BasicEntityPersister.java:1594)
        at 
org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1850)
        at 
org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2200)
        at 
org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:46)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
        at 
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
        at 
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
        at 
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
        at 
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
        at 
com.goldencode.p2j.schema.ImportWorker$Library.importTable(ImportWorker.java:710)
        at 
com.goldencode.p2j.schema.ImportWorker$Library$1.run(ImportWorker.java:1020)
        at java.lang.Thread.run(Thread.java:619)
...

A number of previous inserts contained "unknown" dates.  These were 
bound with PreparedStatement.setNull(index, Types.DATE) before the test 
was tripped by the PreparedStatement.setDate(index, date) in the stack 
trace above.

I will run with the enhanced logging patch and upload results shortly.

Thanks,
Eric Faulhaber



In response to

Responses

pgsql-jdbc by date

Next:From: Eric FaulhaberDate: 2007-09-20 19:26:58
Subject: Re: Batch INSERT failing with error 22P02
Previous:From: Kris JurkaDate: 2007-09-20 17:35:02
Subject: Re: Batch INSERT failing with error 22P02

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group