今天在项目中向数据库的CLOB属性插入一段篇文章(1000~2000)字就会报一个字符串过长的错误。

网上说用流来处理,没有这么做。这像是一个Bug,只要把插入的数据,默认扩充到2000以上就ok了。

下面是这段代码:

if((temp.length()>=1000)&&(temp.length()<=2000)){
            temp=StringUtils.rightPad(temp, 2008);
  }

使用StringUtils的rightPad方法使没超过2000的部分,在右边自动填充0,直到2008长度。

(一个半角字符一个字节,一个全角字符两个字节,所以汉字1000-2000,而英文2000-4000)

相关文章:

  • 2021-09-25
  • 2021-12-31
  • 2021-11-09
  • 2021-06-29
  • 2022-01-25
  • 2021-10-22
  • 2021-05-08
  • 2022-02-24
猜你喜欢
  • 2021-05-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-09-13
  • 2021-06-09
相关资源
相似解决方案