-->
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.  [ 2 posts ] 
Author Message
 Post subject: getting error like "Could not execute JDBC batch update
PostPosted: Fri Nov 11, 2005 3:05 am 
Newbie

Joined: Tue Oct 25, 2005 1:40 am
Posts: 7
I am tryingf simple hibernate example with single database table contaning two fields as follows:-
Name ==datatype->int2 Sequence=public.seq1
Pwd==datatype->varchar


Mapping document is
UsetT.hbm.xml
==========
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="com.hib">
<class name="UsetT" table="usett">
<id name="id" column="Name" type="long">
<generator class="sequence">
<param name="sequence">public.seq1</param>
</generator>
</id>
<property name="pwd" column="Pwd" />
</class>
</hibernate-mapping>

==========

& client java program is:-
PersistUser.java
====
package com.hib;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.HibernateException;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class PersistUser
{
public static void main(String[] args) throws java.text.ParseException {
PersistUser instance = new PersistUser();
String title = "Prashant";
instance.store(title);
System.exit(0);
}

private void store(String title) {
try {
Session session = HibernateSessionFactory.currentSession();
Transaction tx = session.beginTransaction();
UsetT theEvent = new UsetT();
theEvent.setPwd(title);
session.save(theEvent);
tx.commit();
HibernateSessionFactory.closeSession();
} catch (HibernateException e) {
e.printStackTrace();
}
}
}
====



all the sessionfactory file is generated successfully.
After running my abobe client prog. -"PersistUser.java" i m getting following error


org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:181)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
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 org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at com.hib.PersistUser.main(PersistUser.java:24)
Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into usett (Pwd, Name) values (Prashant, 20) was aborted. Call getNextException to see the cause.
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2376)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1161)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:328)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2435)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
... 8 more
======


pls help me to solve this
Pras....


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 3:22 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Try to execute the insert statement directly in your DB. It's most likely a mapping error.

I'm using http://www.p6spy.com to get nice JDBC logs.

HTH
Ernst


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.