import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import net.jaekl.cfb.db.Column;
int index = 0;
for (Condition condition : conditions) {
if (condition.getOperation().hasParam()) {
+ Column column = condition.getColumn();
index++;
- ps.setObject(index, condition.getValue());
+ column.setObject(ps, index, condition.getValue());
}
}
}
}
}
+ catch (SQLException se) {
+ throw new SQLException("Error with SQL: " + sql, se);
+ }
return result;
}
assert(null != data);
assert(data.length == table.getNumColumns());
- for (int col = 0; col < data.length; ++col) {
- Object obj = data[col];
- Column column = table.getColumn(col);
- if (column.getType().equals(Type.TIMESTAMPTZ)) {
- // Special case: because there's no good way to read a TIMESTAMPTZ from
- // the database using JDBC, we store it as an integer (milliseconds since
- // the epoch, 01.01.1970 00:00:00.000 UTC).
- Date date = (Date)obj;
- ps.setLong(col + 1, date.getTime());
- }
- else {
- ps.setObject(col + 1, data[col]);
- }
+ for (int idx = 0; idx < data.length; ++idx) {
+ Object obj = data[idx];
+ Column column = table.getColumn(idx);
+ column.setObject(ps, idx + 1, obj);
pendingValues++;
}
ps.addBatch();
sb.append(sort.getColumn().getName());
if (sort.getDirection().equals(Sort.Direction.ASCENDING)) {
- sb.append(" ASCENDING ");
+ sb.append(" ASC ");
}
else {
- sb.append(" DESCENDING ");
+ sb.append(" DESC ");
}
}
}