oracle jdbc cachedrowset 구현을 사용하여 쿼리에서 반환되는 여러 행을 선택합니다. 그런 다음 cachedrowset.updateInt() 또는 다른 업데이트 메소드를 사용하여 일부 데이터를 업데이트합니다. 나는 처음에 cachedrowset.beforeFirst()를 사용하여 커서를 다시 얻은 다음 다시 행 집합을 탐색하여 데이터를 인쇄합니다.OracleCachedRowSet 데이터베이스에 쓰지 않고 메모리의 데이터를 업데이트합니다.
데이터가 원래 getInt()를 사용하여 얻은 데이터입니다. 다시 원래 데이터로 바뀝니다. 원래 데이터로 대체되는 데이터를 가져오고 싶습니다. 나는 db에 변경을가하도록 의도하지 않았습니다.
나는 데이터 조작 및 뷰에 대해서만 DB의 데이터를 변경하지 않고 Rowset 개체를 데이터 래퍼로 사용할 수 있다고 생각했습니다. 원래 날짜 대신 업데이트 된 날짜를 얻을 수있는 방법이 있습니까? 난 내 자신의
편집의 데이터 래퍼 객체를 코딩하고 싶지 않았다
public void updateRowSetData(CachedRowSet cachedRowSet, int columnIndex, int columnType, Object data)
throws SQLException {
switch (columnType) {
case Types.NUMERIC:
case Types.DECIMAL:
cachedRowSet.updateBigDecimal(columnIndex, (BigDecimal) data);
return;
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGNVARCHAR:
cachedRowSet.updateString(columnIndex, data == null ? null : data.toString());
return;
case Types.INTEGER:
cachedRowSet.updateInt(columnIndex, (Integer) data);
return;
case Types.DATE:
cachedRowSet.updateDate(columnIndex, (Date) data);
return;
case Types.TIMESTAMP:
cachedRowSet.updateTimestamp(columnIndex, (Timestamp) data);
return;
case Types.TIME:
cachedRowSet.updateTime(columnIndex, (Time) data);
return;
case Types.BIGINT:
cachedRowSet.updateLong(columnIndex, data == null ? null : Long.parseLong(data.toString()));
return;
case Types.DOUBLE:
case Types.FLOAT:
cachedRowSet.updateDouble(columnIndex, (Double) data);
return;
case Types.SMALLINT:
cachedRowSet.updateShort(columnIndex, data == null ? null : Short.parseShort(data.toString()));
return;
case Types.TINYINT:
cachedRowSet.updateByte(columnIndex, Byte.parseByte(data == null ? null : data.toString()));
return;
case Types.BINARY:
case Types.VARBINARY:
cachedRowSet.updateBytes(columnIndex, (byte[]) data);
return;
case Types.CLOB:
if (data != null) {
cachedRowSet.updateClob(columnIndex, ((Clob) data).getCharacterStream());
} else {
cachedRowSet.updateClob(columnIndex, (Clob) data);
}
return;
case Types.ARRAY:
cachedRowSet.updateArray(columnIndex, (Array) data);
return;
case Types.BLOB:
if (data != null) {
cachedRowSet.updateBlob(columnIndex, data == null ? null : ((Blob) data).getBinaryStream());
} else {
cachedRowSet.updateBlob(columnIndex, (Blob) data);
}
return;
case Types.REAL:
cachedRowSet.updateFloat(columnIndex, (Float) data);
return;
case Types.BIT:
case Types.BOOLEAN:
cachedRowSet.updateBoolean(columnIndex, (Boolean) data);
return;
case Types.REF:
cachedRowSet.updateRef(columnIndex, (Ref) data);
return;
case Types.LONGVARBINARY:
cachedRowSet.updateBinaryStream(columnIndex, (InputStream) data);
return;
default:
cachedRowSet.updateObject(columnIndex, data);
return;
}
}
가 나는 것을 시도를하지만, 불행히도 게시 할 수 – Bren
를 작동하지 않았다 당신이 작업하고있는 몇 가지 샘플 코드? – Santosh
물론, 내 질문에 따라 editted @ Santosh – Bren