CREATE TABLE SUGGEST_DATA (
LOCALE VARCHAR2(20) NOT NULL,
DATA_COLLECTION blob,
UPDATED_ON TIMESTAMP,
PRIMARY KEY (LOCALE)
)
使用以下代码将哈希表(键=字符串,值=字符串的ArrayList)插入到上表中。
Java代码:-
conn = getDBConnection();
stmt = conn.prepareStatement("INSERT INTO SUGGEST_DATA (LOCALE,DATA_COLLECTION,UPDATED_ON) VALUES (?, ?, ?)");
stmt.setString(1, locale);
stmt.setObject(2, data);//this is a java hashtable
stmt.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
stmt.executeUpdate();
在“ stmt.setObject”上失败
java.sql.SQLException: Invalid column type
at oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:11256)
at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:10605)
at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:11665)
at oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:11631)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.setObject(OraclePreparedStatementWrapper.java:253)