File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Any Possibilities to get other than SQLException while using executeUpdate()  method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Any Possibilities to get other than SQLException while using executeUpdate()  method" Watch "Any Possibilities to get other than SQLException while using executeUpdate()  method" New topic
Author

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

BalaiahRaju ChamarthiRaju
Greenhorn

Joined: Sep 18, 2007
Posts: 13
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

Joined: Mar 06, 2001
Posts: 13459

You would need to post some code, but it is still possible for the close operations to throw exceptions.
BalaiahRaju ChamarthiRaju
Greenhorn

Joined: Sep 18, 2007
Posts: 13
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30392
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
Don't get me started about those stupid light bulbs.
 
subject: Any Possibilities to get other than SQLException while using executeUpdate() method