I have a Question to ExceptionHandling on java.sql.PreparedStatement.
I have an PreparedStatement:
insertTEZDETAIL = new XPreparedStatement(con, "INSERT INTO TEZDETAIL (PACKAGE_ID, LFDNR, ARCHIVTAG, PAYINF)"
+ " Values(?, ?, ? ,XMLPARSE(DOCUMENT CAST(? AS CLOB)))" );
and Add many Statements in Batch:
insertTEZDETAIL.setInt(1, paket_id);
insertTEZDETAIL.setInt(2, Counter1);
insertTEZDETAIL.setString(3, archiv_dat);
SQLXML xmlvar = con.createSQLXML();
xmlvar.setString(gesXML.toString());
insertTEZDETAIL.setSQLXML(4, xmlvar);
insertTEZDETAIL.addBatch();
Now I execute it Batch:
public static void DB2Commit()
{
try
{ insertTEZDETAIL.executeBatch();
} catch (SQLException ex)
{ for ( ; ex != null ; ex = ex.getNextException ())
{
ex.printStackTrace ();
}
try
{
con.rollback();
} catch (SQLException e) {
e.printStackTrace();
System.exit(12);
}
System.err.println("Fehler beim execute Batch");
System.exit(12);
}
}
With the "Forech exception loop" I get all Exception, but it there a way to get the GeneratedKey's of this Statement where the exception is? With RETURN_GENERATED_KEYS it doesnt work, may because of the Batch?? Or maybe to get the Statement it self?? Because I have a class to printout the complete Statement with generatedKey's, just like the DB2 get the Statement.
Thanks for Answers,
Florian