ORA-12899:列XX的值太大(实际值:521,最大值:512)(三)

2014-11-24 09:16:40 · 作者: · 浏览: 3
mpl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723) at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268) ... 55 more

疑问:明明对将要插入的字符串做了subString(0,512),为什么说实际值为521,?

解答:这是因为要插入的字符串含有中文,中文在subString时是占据一个位置,但在数据库中不止一个位置。

解决:1、对插入的字符串尽量截取少点,如subString(0, 400)

2、对插入的字符串编码先编码处理再截取,如Urlencoder.encode(str, "utf-8"),这样subString(0,512)是对的