关于网友提出的“ java 连接oracle插入不了数据”问题疑问,本网通过在网上对“ java 连接oracle插入不了数据”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: java 连接oracle插入不了数据
描述:JavaOracle
public int addDestine(Destineinfo destine) {
Connection conn = this.getConnection();
PreparedStatement pstmt = null;
int count = 0;
String sql = "insert into destineinfo "
+ "values(destine_seq.nextval,?,"
+ "TO_DATE(?,'yyyy-MM-dd hh24:mi:ss'),?)";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, destine.getRoomName());
pstmt.setString(2, destine.getDestineDate());
pstmt.setString(3, destine.getDestineName());
count = pstmt.executeUpdate();<>
} catch (SQLException e) {
e.printStackTrace();
} finally {
this.clossAll(conn, pstmt, null);
}
return count;
}
貌似代码没错。但是运行报错,插入不了数据
java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:304)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:271)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:622)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:180)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_rows(T4CPreparedStatement.java:542)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1027)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2887)