public int insert(Order order)
throws SQLException
{
PreparedStatement insert = null;
int orderKey = -1;
try
{
String method = new String("DBInterface.insert( Order )");
FileLogger.log(FileLogger.HIGH, method + " - Entering...");
int col = 0;
int actionCode = getCodeKey("ORDER_ACTION", order._action);
int statusCode = getCodeKey("PCO_AUTO_STATUS", order._status);
int falloutTypeCode = getCodeKey("FALLOUT_TYPE", order._falloutType);
orderKey = getSequenceNo("TC_ORDER_SEQ");
int primaryClfiKey = lookupByValue("TC_CLFI", order._primaryClfi);
FileLogger.log(FileLogger.HIGH,
"accessing fac_assembly: " + order._facAssembly);
int facAssemblyKey = lookupByValue("TC_FAC_ASSEMBLY", order._facAssembly);
FileLogger.log(FileLogger.HIGH,
"after accessing fac_assembly: " + order._facAssembly);
int pcoClliKey = lookupByValue("TC_CLLI", order._pcoClli);
String stmt = new String("INSERT INTO TC_ORDER (ORDER_KEY, ORDER_NUMBER, PCO_CLLI_KEY, PRIMARY_CLFI_KEY, ACTION_CD_KEY,
DUE_DATE, ISSUE_DATE, CUT_CODE, PON, FAC_ASSEMBLY_KEY, ORDER_MSG_RAW, AUTO_STATUS_CD_KEY, START_DT, FALLOUT_TYPE_CD_KEY, FAL
LOUT_TO_OSDS_FG ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ");
FileLogger.log(FileLogger.HIGH, stmt);
insert = _conn.prepareStatement(stmt);
insert.setInt(++col, orderKey);
insert.setString(++col, order._orderNumber);
insert.setInt(++col, pcoClliKey);
insert.setInt(++col, primaryClfiKey);
insert.setInt(++col, actionCode);
insert.setTimestamp(++col, new java.sql.Timestamp(order._dueDate.getTime()));
insert.setTimestamp(++col,
new java.sql.Timestamp(order._issueDate.getTime()));
insert.setString(++col, order._cutCode);
insert.setString(++col, order._PON);
insert.setInt(++col, facAssemblyKey);
InputStream is = new ByteArrayInputStream(order._xmlMsg.getBytes());
StringReader reader = new StringReader(order._xmlMsg);
insert.setCharacterStream(++col, reader, order._xmlMsg.length());
insert.setInt(++col, statusCode);
insert.setTimestamp(++col,
new java.sql.Timestamp(order._startDate.getTime()));
insert.setInt(++col, falloutTypeCode);
insert.setShort(++col, order._falloutToOsds);
insert.executeUpdate();
FileLogger.log(FileLogger.HIGH, method + "Returning key: " + orderKey);
return orderKey;
}
catch (SQLException sqle)
{
FileLogger.log(FileLogger.ERROR,
"DBInterface.insert(Order) - caught and will throw " +
sqle.toString() +
"; error code: " + sqle.getErrorCode() +
"; sql state: " + sqle.getSQLState() +
"; next exception: " + sqle.getNextException());
FileLogger.debug(order);
throw sqle;
}
finally
{
FileLogger.log(FileLogger.HIGH,
"DBInterface.insert(Order) - cleaning up...");
insert.close();
}
}
I get an error at the above finally block for nullpoint exception at inser.close() line. Please help