---
title: "ibatis oracle 长字符串 bug"
author: "kimnin"
date: "2009-08-06T10:52:00Z"
tags: []
slug: "ibatis-oracle-bug"
draft: false
lastmod: "2009-08-06T10:52:00Z"
id: 441361
url: "https://kimnin.iteye.com/blog/441361"
---

ibatis ： ibatis-2.3.4.726.jar  
&lt;update id="update" parameterClass="org.kimnin.test4000.Test4000PO"&gt;  
        update test4000 set str=#str#    where id=#id#  
&lt;/update&gt;

&lt;insert id="insert" parameterClass="org.kimnin.test4000.Test4000PO"&gt;  
        insert into test4000(id ,str)values( #id# ,#str#)  
&lt;/insert&gt;

   public void test4000insert() throws Throwable {  
      Test4000PO test = new Test4000PO();  
      test.setId(3);  
      test.setStr(\_1000 + \_1000 + \_1000 + \_1000);//\_1000是长度为1k的的字符串  
      System.out.println(test.getStr().length());  
      sqlMap.insert("insert", test);  
   }  
    
   public void test4000update() throws Throwable {  
      Test4000PO test = new Test4000PO();  
      test.setId(2);  
      test.setStr(\_1000 + \_1000 + \_1000 + \_1000);  
      System.out.println(test.getStr().length());  
      sqlMap.update("update", test);  
   }  
    
在Oranxo-3.00.01.jar  
&lt;property name="JDBC.Driver" value="com.inet.ora.OraDriver" /&gt;  
&lt;property name="JDBC.ConnectionURL" value="jdbc:inetora:10.224.56.42:1521:webdb" /&gt;  
             
在驱动为：  
Oranxo-3.00.01.jar  
使用配置文件：  
&lt;property name="JDBC.Driver" value="com.inet.ora.OraDriver" /&gt;  
&lt;property name="JDBC.ConnectionURL" value="jdbc:inetora:10.224.56.42:1521:webdb" /&gt;  
insert 成功  
update 失败

在驱动为：  
Oranxo-3.00.01.jar  
使用jdbc方式:  
insert 成功  
update 成功                   

在驱动为：  
ojdbc14.jar  
orai18n.jar  
使用配置文件：  
&lt;property name="JDBC.Driver" value="oracle.jdbc.driver.OracleDriver" /&gt;  
&lt;property name="JDBC.ConnectionURL" value="jdbc:oracle:thin:@10.224.56.42:1521:webdb" /&gt;  
insert 成功  
update 成功                   

Mysql环境下使用配置文件：  
&lt;property name="JDBC.Driver" value="com.mysql.jdbc.Driver" /&gt;  
&lt;property name="JDBC.ConnectionURL" value="jdbc:mysql://localhost/test" /&gt;  
insert 成功  
update 成功

结论  
iBATIES在使用Oranxo-3.00.01.jar配合上有问题.  
有可能是调用驱动，实现update功能时，调用方式不对导致update在字符串长度为大于1333个时出现问题。