Instance retVal = null;
Connection connection = null;
try {
BusinessProcess businessProcess = getGraphByID( businessProcessID );
String sql = "insert into bpm_instance" +
" ( instanceid, processid, graphname, params, status )" +
" values ( ?, ?, ?, ?, ? )";
int instanceID = generateKey();
connection = getConnection();
PreparedStatement preparedStatement =
connection.prepareStatement( sql );
preparedStatement.setInt( 1, instanceID );
preparedStatement.setInt( 2, businessProcessID.getID() );
preparedStatement.setString( 3, businessProcess.getName() );
preparedStatement.setBytes( 4, SerializeUtil.serializeAppParam( params ) );
preparedStatement.setInt( 5, Instance.STATUS_RUNNING );
preparedStatement.execute();
preparedStatement.close();