I found the cause of this problem.. was the formatting of my query that was
preventing it from running.
I have some more strange
| private void storeRow() throws SQLException
| {
| String updateStatement =
| "update Account set " +
| "credit = ?, " +
| "discount = ?, " +
| "openedDate = ?, " +
| "closedDate = ?, " +
| "where id = ?";
| PreparedStatement prepStmt = con.prepareStatement(updateStatement);
|
| prepStmt.setInt(1, this.m_id.intValue());
| prepStmt.setDouble(2, this.m_credit);
| prepStmt.setDouble(3, this.m_discount);
| prepStmt.setDate(4, new java.sql.Date(this.m_openedDate.getTime()));
| prepStmt.setDate(5, new java.sql.Date(this.m_closedDate.getTime()));
|
| int rowCount = prepStmt.executeUpdate();
| prepStmt.close();
|
| if (rowCount == 0)
| {
| throw new EJBException("Storing row for id " + m_id + " failed.");
| }
| }
| }
|
I had to change to the following so the ID is entered into the last space in
the query which it was not doing before.
| private void storeRow() throws SQLException
| {
| String updateStatement =
| "update Account set " +
| "credit = ?, " +
| "discount = ?, " +
| "openedDate = ?, " +
| "closedDate = ?, " +
| "where id = ?";
| PreparedStatement prepStmt = con.prepareStatement(updateStatement);
|
| prepStmt.setDouble(1, this.m_credit);
| prepStmt.setDouble(2, this.m_discount);
| prepStmt.setDate(3, new java.sql.Date(this.m_openedDate.getTime()));
| prepStmt.setDate(4, new java.sql.Date(this.m_closedDate.getTime()));
| prepStmt.setInt(5, this.m_id.intValue());
|
| int rowCount = prepStmt.executeUpdate();
| prepStmt.close();
|
| if (rowCount == 0)
| {
| throw new EJBException("Storing row for id " + m_id + " failed.");
| }
| }
| }
|
But the problem has now changed..........
ejbStore dies on the same error after I call my create method, but now works
fine after I call a finder method?
| public Integer ejbCreate(Integer id, double credit , double discount,
java.util.Date openedDate, java.util.Date closedDate)
|
| throws CreateException
| {
| try
| {
| insertRow(id, credit, discount, openedDate, closedDate);
| }
| catch (Exception ex)
| {
| throw new EJBException("ejbRemove: " + ex.getMessage());
| }
|
| this.m_id = id;
| this.m_credit = credit;
| this.m_discount = discount;
| this.m_openedDate = openedDate;
| this.m_openedDate = closedDate;
|
| return this.m_id;
| }
Its almost as if its trying to sync the bean with persistant storage before the
create method has a chance to insert to the database.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3954885#3954885
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3954885
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user