+ "\nat : " + dumpTime + "\ndump format version : " + dumpVersion);
if (whereClause != null) {
HenPlus.msg().println("projection : " + whereClause);
}
final ProgressWriter progressWriter = new ProgressWriter(estimatedRows, HenPlus.msg());
importedRows = 0;
problemRows = 0;
_running = true;
while (_running) {
skipWhite(reader);
inCh = (char) reader.read();
if (inCh == ')') {
break;
}
if (inCh != '(') {
raiseException(reader, "'(' or ')' expected");
}
// we are now at the beginning of the row.
++importedRows;
progressWriter.update(importedRows);
for (int i = 0; i < metaProperty.length; ++i) {
final int col = i + 1;
final int type = metaProperty[i].type;
switch (type) {
case HP_NUMERIC:
case HP_DOUBLE:
case HP_INTEGER: {
final Number number = readNumber(reader);
if (stmt != null) {
if (number == null) {
if (type == HP_NUMERIC) {
stmt.setNull(col, Types.NUMERIC);
} else if (type == HP_INTEGER) {
stmt.setNull(col, Types.INTEGER);
} else if (type == HP_DOUBLE) {
stmt.setNull(col, Types.DOUBLE);
}
} else {
if (number instanceof Integer) {
stmt.setInt(col, number.intValue());
} else if (number instanceof Long) {
stmt.setLong(col, number.longValue());
} else if (number instanceof Double) {
stmt.setDouble(col, number.doubleValue());
} else if (number instanceof BigDecimal) {
stmt.setBigDecimal(col, (BigDecimal) number);
}
}
}
break;
}
case HP_TIMESTAMP: {
final String val = readString(reader);
metaProperty[i].updateMaxLength(val);
if (stmt != null) {
if (val == null) {
stmt.setTimestamp(col, null);
} else {
stmt.setTimestamp(col, Timestamp.valueOf(val));
}
}
break;
}
case HP_TIME: {
final String val = readString(reader);
metaProperty[i].updateMaxLength(val);
if (stmt != null) {
if (val == null) {
stmt.setTime(col, null);
} else {
stmt.setTime(col, Time.valueOf(val));
}
}
break;
}
case HP_DATE: {
final String val = readString(reader);
metaProperty[i].updateMaxLength(val);
if (stmt != null) {
if (val == null) {
stmt.setDate(col, null);
} else {
stmt.setDate(col, java.sql.Date.valueOf(val));
}
}
break;
}
case HP_BLOB: // we try our best by reading BLOB/CLOB
case HP_CLOB: // as String (known not to work on Oracle
case HP_STRING: {
final String val = readString(reader);
metaProperty[i].updateMaxLength(val);
if (stmt != null) {
stmt.setString(col, val);
}
break;
}
case HP_BOOLEAN:
final String val = readToken(reader);
metaProperty[i].updateMaxLength(1);
if (stmt != null) {
stmt.setBoolean(col, Boolean.valueOf(val));
}
break;
default:
throw new IllegalArgumentException("type " + TYPES[metaProperty[i].type] + " not supported yet");
}
expect(reader, i + 1 < metaProperty.length ? ',' : ')');
}
try {
if (stmt != null) {
stmt.execute();
}
} catch (final SQLException e) {
String msg = e.getMessage();
// oracle adds CR for some reason.
if (msg != null) {
msg = msg.trim();
}
reportProblem(msg);
++problemRows;
}
// commit every once in a while.
if (hot && commitPoint >= 0 && importedRows % commitPoint == 0) {
conn.commit();
}
}
progressWriter.finish();
} else {
HenPlus.msg().println("ignoring unknown token " + token);
dumpTime = readString(reader);
expect(reader, ')');
}