-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: getNextException SQLGrammarException
PostPosted: Mon Sep 29, 2008 7:04 am 
Regular
Regular

Joined: Tue Jun 03, 2008 1:12 pm
Posts: 84
Location: germany
How can I get the nextException from a SQLGrammarException?

I use Hibernate and want to store a record and get the following exception. (I know the meaning of SQL Error -301, but I cannot find the field which has a false datatype. So I need the getNextException to know which field is wrong.)

Code:
08:01:25,733 WARN  [JDBCExceptionReporter] SQL Error: -99999, SQLState: null
08:01:25,733 ERROR [JDBCExceptionReporter] Non-atomic batch failure.  The batch was submitted, but at least one exception occurred on an individual member of the batch. Use getNextException() to retrieve the exceptions for specific batched elements.
08:01:25,733 WARN  [JDBCExceptionReporter] SQL Error: -301, SQLState: 07006
08:01:25,733 ERROR [JDBCExceptionReporter] Error for batch element #0: DB2 SQL error: SQLCODE: -301, SQLSTATE: 07006, SQLERRMC: 10
08:01:25,733 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
...
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
   at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:92)

Caused by: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
   at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:92)
   at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:87)
   at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:222)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2224)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
   at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:56)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
   at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:296)
   ... 149 more
Caused by: com.ibm.db2.jcc.a.ge: Non-atomic batch failure.  The batch was submitted, but at least one exception occurred on an individual member of the batch. Use getNextException() to retrieve the exceptions for specific batched elements.
   at com.ibm.db2.jcc.a.j.a(j.java:397)
   at com.ibm.db2.jcc.a.id.b(id.java:2935)
   at com.ibm.db2.jcc.a.id.a(id.java:2704)
   at com.ibm.db2.jcc.a.id.executeBatch(id.java:2516)
   at com.ibm.db2.jcc.a.id.executeBatch(id.java:1348)
   at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:519)


Now, I want the to "Use getNextException() to retrieve the exceptions for specific batched elements". But this does not print the nextException to my console:
Code:
public void save()
{
try {
//save the record
}
catch (SQLGrammarException ex)  {

while(ex != null) {
                         java.lang.System.out.println(ex.getSQLException().getNextException());
throw (SQLGrammarException) ex;
}
}


But this does not work. The same stacktrace without the "getNextException" occurs. But I need the getNextException to find out, what s wrong.


How can I get the getNextException()???


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 30, 2008 2:17 am 
Regular
Regular

Joined: Tue Jun 03, 2008 1:12 pm
Posts: 84
Location: germany
Can I catch a SQLGrammarException in this case? Or must I catch JDBCExceptionReporter or something else? I have no clue.

It strange that I can not get the next SQLException in Hibernate. Is this not possible?


Top
 Profile  
 
 Post subject: Re: getNextException SQLGrammarException
PostPosted: Tue Apr 24, 2012 7:09 am 
Newbie

Joined: Tue Apr 24, 2012 7:03 am
Posts: 1
Please try catch "JDBCException" and use the method "getSQLException().getNextException()" to meet you need.
For example:
try{ .......... } catch (JDBCException jdbce) { jdbce.getSQLException().getNextException().printStackTrace() }


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.