• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Any Possibilities to get other than SQLException while using executeUpdate() method

 
BalaiahRaju ChamarthiRaju
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am Using PreparedStatement to insert Record into database.
after calling executeUpdate() method. I am writing finally block to close all the stmt,rs..

Record is inserting into Database.. but I am getting Exception.. how it is possible..

is there any possible to get otherthan SQLException.
please let me know..

Thanks in Advance..
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would need to post some code, but it is still possible for the close operations to throw exceptions.
 
BalaiahRaju ChamarthiRaju
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My code is like this
--------------------
String sql="INSERT INTO EXPORT_LOG EXPL_LUW_ID, EXPL_SEQ, EXPL_STAMP, EXPL_TBLA_ID, EXPL_ROW_KEY, EXPL_EMP_ID,EXPL_ACTION, EXPL_C_FIELD_IDS, EXPL_C_VALUES, EXPL_STATUS, EXPL_P_TBLA_ID, EXPL_P_KEY, EXPL_SOURCE )VALUES (?, ?, TO_DAT(?,'YYYYMMDDHH24MISS'), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);

PreparedStatement stmt = null;
Reader reader= null;
try {
stmt = app.getDataConnection().prepareStatement(sql);
stmt.setString(1,expl.getLuwId());
stmt.setInt(2,expl.getSeq());
stmt.setString(3,expl.getStamp());
stmt.setInt(4,expl.getTableId());
stmt.setString(5,expl.getRowKey());
stmt.setInt(6,expl.getEmpId());
stmt.setString(7,expl.getAction().toString());
stmt.setString(8,expl.getChildFieldIds());
if(expl.getChildValues()!=null){
reader=new CharArrayReader(expl.getChildValues().toCharArray());
stmt.setCharacterStream(9, reader, expl.getChildValues().toCharArray().length);
}
else{
stmt.setString(9,expl.getChildValues());
}
stmt.setString(10,expl.getStatus().toString());
stmt.setInt(11,expl.getParentTableId());
stmt.setString(12,expl.getParentKey());
stmt.setString(13,expl.getSource().toString());
stmt.executeUpdate();
} catch(SQLException e){
handleSqlException(e,sql, app);
}
finally {
DbUtils.closeQuietly(stmt);
IOUtils.closeQuietly(reader);
}
}

------------
in the above code, the record is inserting into database, after that it is throwing SQLException, I think this is throwing in finally block.. can you tell me is this possible.
and is there any chaces to get other than SQLException.

-Bala
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34965
377
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bala,
The finally block delegates to the method DbUtils.closeQuietly(stmt). What does that do? One thing that is suspicious is that I can't see where/how the connection is closed. Maybe you have a connection leak?

Posting the actual SQL Exception text might give more clues.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic