我有oracle中的主鍵是CUST_NO和SERIAL_NO的FP_BIOMETRIC_DATA表。 Blob列是FINGER_DATA。所以我想在這張表中插入一條記錄。該代碼如下:stmt.executeUpdate()返回java.sql.SQLException:ORA-01722:無效的數字
public void saveFingerToDatabase(String username , String key , byte[] data)
{
try {
connection = DBConnectionHandler.getConnection();
PreparedStatement stmt = connection.prepareStatement("insert into FP_BIOMETRIC_DATA (CUST_NO,SERIAL_NO,FINGER_DATA,KEY_VALUE) values (?,?,?,?)");
stmt.setInt(1, Integer.parseInt(username));
stmt.setInt(2, 1);
stmt.setBytes(3, data);
stmt.setString(4, key);
stmt.executeUpdate();
connection.commit();
} catch (SQLException ex) {
Logger.getLogger(SaveDataToDatabase.class.getName()).log(Level.SEVERE, null, ex);
}
try {
connection.close();
} catch (SQLException ex) {
Logger.getLogger(SaveDataToDatabase.class.getName()).log(Level.SEVERE, null, ex);
}
}
但是當我運行這段代碼它給我下面的錯誤:
java.sql.SQLException: ORA-01722: invalid number
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:952)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1160)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
at com.Futronic.WorkedEx.SaveDataToDatabase.saveFingerToDatabase(SaveDataToDatabase.java:43)
at com.Futronic.WorkedEx.DbRecord.Save(DbRecord.java:184)
at com.Futronic.WorkedEx.MainForm.OnEnrollmentComplete(MainForm.java:159)
at com.futronic.SDKHelper.FutronicEnrollment.run(FutronicEnrollment.java:234)
at java.lang.Thread.run(Thread.java:745)
我能不明白的地方是錯誤?請幫幫我 。
請顯示DLL和的 「用戶名」 的值,數據,密鑰 – Jens
的用戶名是19, 關鍵是aT8wdC5PT/eAy75BMSOtqA ==和數據是[B @ 6d3538b5 –
的** DDL **, 請。也就是列的定義方式。什麼是列的類型?另外,如果數據是一個數組,則不應該只打印它。數組的'toString'沒有用處。改用'Arrays.toString()'。 – RealSkeptic