コード例 #1
0
 protected static final void fillTables(DbSession session, DbSchema schema)
     throws WaarpDatabaseNoDataException, WaarpDatabaseNoConnectionException,
         WaarpDatabaseSqlException {
   if (schema.constructionOrder == null) {
     schema.createBuildOrder();
   }
   for (String tableName : schema.constructionOrder) {
     DbTable table = schema.getTable(tableName);
     String action = "INSERT INTO " + table.name + "(";
     String fields = "";
     String future = "";
     for (DbField field : table.getFields()) {
       fields += field.name + ",";
       future += "?,";
     }
     fields = fields.substring(0, fields.length() - 1);
     future = future.substring(0, future.length() - 1);
     action += fields + ") VALUES(" + future + ")";
     DbPreparedStatement preparedStatement = new DbPreparedStatement(session);
     preparedStatement.createPrepareStatement(action);
     for (DbTableRow tableRow : table.getRows()) {
       int i = 0;
       for (DbFieldValue value : tableRow.getValues()) {
         PreparedStatement prStatement = preparedStatement.getPreparedStatement();
         i++;
         DbVitam2Database.setTrueValue(prStatement, value, i);
       }
       int count = preparedStatement.executeUpdate();
       if (count <= 0) {
         throw new WaarpDatabaseNoDataException("No row inserted");
       }
     }
   }
 }
コード例 #2
0
 protected static void addOneTableRow(
     DbPreparedStatement preparedStatement, DbTable table, String[] values, int rank, int startCol)
     throws WaarpDatabaseSqlException, WaarpDatabaseNoConnectionException,
         WaarpDatabaseNoDataException {
   PreparedStatement prStatement = preparedStatement.getPreparedStatement();
   for (int j = startCol; j < values.length; j++) {
     DbFieldValue value = new DbFieldValue(table.getField(j - startCol), values[j]);
     DbVitam2Database.setTrueValue(prStatement, value, j - startCol + 1);
   }
   int count = preparedStatement.executeUpdate();
   if (count <= 0) {
     throw new WaarpDatabaseNoDataException("No row inserted");
   }
 }