"update DO_Code_MaxSequence SET max_sequence=max_sequence+1")
.append(" WHERE upper(code_ItemUid)=?");
Connection con = null;
PreparedStatement stmt = null;
DOBO bo = DOBO.getDOBOByName("do_authorization");
DODataSource dss = bo.getDataBase();
try {
// query
con = dss.getContextConnection();
stmt = con.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
int retId = 1;
stmt.setString(1, codeItemID);
ResultSet rs = stmt.executeQuery();
System.out.println("The SQL" + sql);
if (rs.next()) {
retId = rs.getInt("max_sequence") + 1;
// update
// //update
stmt = con.prepareStatement(sqlUpdate.toString());
stmt.setString(1, codeItemID);
stmt.execute();
} else {
// //////////////insert
stmt = con.prepareStatement(insertSql.toString());
stmt.setString(1, UUIDHex.getInstance().generate());
stmt.setString(2, null);
stmt.setString(3, codeItemID);
stmt.setString(4, null);
stmt.setInt(5, 0);
stmt.setLong(6, retId);
stmt.execute();
}
// stmt.close();
//
return retId;
} catch (SQLException ex) {
try {
con.rollback();
} catch (SQLException e) {
}
ex.printStackTrace();
return 0;
} finally {// Close Connection
try {
if (stmt != null) {
stmt.close();
}
dss.ifCloseConnection(con);
} catch (Exception ex1) {
ex1.printStackTrace();
}
}
}