-->
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: Hibernate GenericJDBCException: Could not execute JDBC batch
PostPosted: Wed Feb 16, 2011 5:46 pm 
Newbie

Joined: Fri Apr 30, 2010 5:17 pm
Posts: 13
I am having trouble writing to my database. I apologize that I don't have a stack trace to show you. I think the system is trying to write the values in the wrong order, because when I write, I'm getting this message in the console (please note that id is the last parameter here):

Code:
Hibernate: insert into bulletins (bulletin_date, name, subject, bulletin, approved, id) values (?, ?, ?, ?, ?, ?)
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update


Yet when the custom tag I am referencing in the JSP reads from the same table, here is what appears in the console (please note that id is the first parameter here):

Code:
Hibernate: select bulletin0_.id as id, bulletin0_.bulletin_date as bulletin2_3_, bulletin0_.name as name3_, bulletin0_.subject as subject3_, bulletin0_.bulletin as bulletin3_, bulletin0_.approved as approved3_ from bulletins bulletin0_ where bulletin0_.approved=true


Can anyone help me here? Here is the writeBulletin() method in my DAO class:

Code:
   public boolean writeBulletin(String name, String subject, String date,
         String note) {
      Bulletin bulletin = new Bulletin();
      request = ServletActionContext.getRequest();
      boolean successfulWrite;
      SessionFactory sessionFactory = (SessionFactory) request.getSession()
            .getServletContext().getAttribute("sessionFactory");
      Session session = sessionFactory.openSession();

      try {
         bulletin.setName(name);
         bulletin.setNote(note);
         bulletin.setDate(date);
         bulletin.setApproved(false);

         Transaction tx = session.beginTransaction();
         session.save(bulletin);
         tx.commit();
         successfulWrite = true;
      } catch (Exception e) {
         System.out.println(e.toString());
         successfulWrite = false;
      } finally {
         session.close();
      }

      return successfulWrite;
   }


For the record, here is the description of my table:

Code:
mysql> describe bulletins;
+---------------+--------------+------+-----+---------+-------+
| Field         | Type         | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| id            | int(11)      | NO   | PRI | NULL    |       |
| bulletin_date | varchar(10)  | NO   |     | NULL    |       |
| name          | varchar(30)  | NO   |     | NULL    |       |
| subject       | varchar(50)  | NO   |     | NULL    |       |
| bulletin      | varchar(250) | NO   |     | NULL    |       |
| approved      | tinyint(1)   | NO   |     | NULL    |       |
+---------------+--------------+------+-----+---------+-------+
6 rows in set (0.01 sec)


Here, also, is Bulletin.hbm.xml:
Code:
<?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>
    <class name="model.Bulletin" table="bulletins">
        <id name="id" column="id" type="java.lang.Integer">
           <generator class="increment" />
        </id>
        <property name="date" column="bulletin_date" type="java.lang.String" />
        <property name="name" column="name" type="java.lang.String" />
        <property name="subject" column="subject" type="java.lang.String" />
        <property name="note" column="bulletin" type="java.lang.String" />
        <property name="approved" column="approved" type="java.lang.Boolean" />       
    </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: Hibernate GenericJDBCException: Could not execute JDBC batch
PostPosted: Wed Feb 16, 2011 7:57 pm 
Newbie

Joined: Fri Apr 30, 2010 5:17 pm
Posts: 13
Problem resolved -- I forgot to set one field with user's input.


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.