您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> Java >> java 连接oracle插入不了数据

java 连接oracle插入不了数据

来源:网络整理     时间:2016/6/27 22:11:54     关键词:

关于网友提出的“ 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) at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:2959) at com.dao.impl.DestineinfoDaoImpl.addDestine(DestineinfoDaoImpl.java:57)
at test.Test.main(Test.java:26)<>
解决方案1:

new Destineinfo("十一","1020-2-2","wang");   pstmt.setString(2, destine.getDestineDate()); 打印一下destine.getDestineDate()是什么格式,请传入yyyy-MM-dd hh24:mi:ss格式的字符串

解决方案2:

楼上说的是对的,字段类型不符合

解决方案3:

1、插入到字符串长度大于4000字节。2、插入到表中的记录的某个字段数据的实际长度大于2000个字节(如果是UTF-8,则是1333个字节);或者是插入的记录中有两个或两个以上长度大于2000字节的字符串。

解决方案4:

destineinfo表结构定义请讲一下。

解决方案5:

是不是字符串长度太长了?

解决方案6:

实体类的代码看看,类型有问题

解决方案7:

很明确了,Long字段插入了非Long型值

解决方案8:

看你的字段和值是否一一对应,貌似偏了


以上介绍了“ java 连接oracle插入不了数据”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/2113945.html

相关图片

相关文章