-->
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: JDBCException: Could not execute JDBC batch update/insert
PostPosted: Thu Jun 10, 2004 9:53 pm 
Newbie

Joined: Sat Feb 28, 2004 4:42 pm
Posts: 7
Location: Oakland, California USA
Hello,

I'm doing what would seem to be a simple operation to save a bean to a table, which generates:

net.sf.hibernate.JDBCException: Could not execute JDBC batch update

I've tried removing the transaction code and doing a flush(), but have the same problem.

I've been going through the code for the last couple of days trying analyze what might be causing it. Class HibernateUtil is taken directly from the Hibernate Reference Manual.

Any ideas what might be causing this? Thanks!

Tomcat: tomcat-4.1.27
mySQL v 4.0.18
driver: com.mysql.jdbc.Driver
Hibernate: hibernate2.jar (12/03) - how to tell the specific version number?
<code>
public boolean regUser(MemberRegBean mrb) {
Session sess = null;
Transaction tx = null;

try {
sess = HibernateUtill.currentSession();
tx = sess.beginTransaction();
sess.save(mrbean);
tx.commit(); // ****** THIS GENERATES JDBCException ************
HibernateUtil.closeSession();
return true;
}
catch(HibernateException he) {
appLogger.debug("MemberDB regUser error: " + he);
return false;
}
}

============================

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.datasource">java:comp/env/jdbc/aft2121</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>

<!--Mapping files -->
<mapping resource="/com/aft2121/memberServicesBeans/MemberRegBean.hbm.xml"/>
<mapping resource="/com/aft2121/memberServicesBeans/PayrollRecordBean.hbm.xml"/>
<!--mapping resource="MemberRegBean.hbm.xml"/-->
</session-factory>
</hibernate-configuration>

=============================

<hibernate-mapping>
<class name="com.aft2121.memberServicesBeans.MemberRegBean" table="registration">

<id name="id" column="id" type="string">
<generator class="uuid.hex"/>
</id>
<property name="firstName" column="firstName" type="string"/>
<property name="lastName" column="lastName" type="string"/>
<property name="last4SSN" column="last4SSN" type="string"/>
<property name="areaCode" column="areaCode" type="string"/>
<property name="phoneNumber" column="phoneNumber" type="string"/>
<property name="email" column="email" type="string"/>
<property name="userID" column="userID" type="string"/>
<property name="passwd" column="passwd" type="string"/>
</class>
</hibernate-mapping>

==========================

DEBUG Thread-5 member_services_application - net.sf.hibernate.JDBCException: Could not execute JDBC batch update
</code>
With:
<code>
<property name="hibernate.jdbc.batch_size">0</property>
</code>
added to hibernate.cfg.xml, the same code above generates:
<code>
DEBUG Thread-4 member_services_application - net.sf.hibernate.JDBCException: could not insert: [com.aft2121.memberServicesBeans.MemberRegBean#ff808081fd11514b00fd11514ee20001]
Code:
Code:
Code:
Code:


Top
 Profile  
 
 Post subject: Always print a full stack trace using printStackTrace()
PostPosted: Fri Jun 11, 2004 1:50 pm 
Newbie

Joined: Sat Feb 28, 2004 4:42 pm
Posts: 7
Location: Oakland, California USA
I found the what was causing the "failure to batch update" / "insert failed" problem - a field mis-spelled in the bean.hbm.xml file. The moral of the story is that I found the error by printing the FULL stack trace, which I had neglected to do. So it does pay to follow the instructions for posting carefully and completely!


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.