OraclePreparedStatement的问题! 
今天在
String sql = "insert into TMP_PERSON (CODE, NAME) values(SEQ_TMP_PERSON.NEXTVAL, ?)";
conn = ConnPool.getConnection();
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,person.getName());
报了ORA-01461: can bind a LONG value only for insert into a LONG column个异常。
发现是在绑定person.getName()的时候抛出的
但又不知道怎么解决,希望能有人解答,谢谢!
或者给我OraclePreparedStatement的源码也行!谢谢!

解决方案 »

  1.   

    谢谢,帮个忙!
    肯定不是数据库设的LONG型而插入的不是此类型或插入大数据量的问题。
    我只插入了两个日文字,而且一直传到插入前还不是乱码。
      

  2.   

    The cause and solution to the issue is as follows:Following reference helped to solve this problem:Item CR60341 under the section “Known Limitations and Workarounds” in the Weblogic release notes: http://edocs.bea.com/wlp/docs40/relnotes/relnotes.htm  This error occurs when there is a mismatch between the character set specification of the Oracle server and the Oracle clients. The Oracle client’s character set should be the same or subset of the Oracle server’s character set. Character sets are used to actually STORE locale-dependant data. When clients from different locales connect to the database, automatic conversion of character sets takes place in the background to display the data properly (based on the NLS_LANG setting on the client). When a client in a different locale sends data back to Oracle, same conversion takes place before data is actually stored. When the character sets on the clients and server do not match, such an error is thrown. To ensure the character set compatibility between the Oracle clients & server, the “NLS_LANG” parameter should match. The Oracle server’s NLS_LANG setting can be found out as follows:Fire the following query to get the full set of NLS settings of the database: SELECT * FROM NLS_DATABASE_PARAMETERS; 
    The NLS_LANG parameter is <language>_<territory>. <Characterset> 
    NLS_LANG=<NLS_LANGUAGE>_<NLS_TERRITORY>.<NLS_CHARACTERSET> 
    The OST4 Oracle9i has been set up with UTF8 character set. Its NLS_LANG parameter is AMERICAN_AMERICA.UTF8. However the NLS_LANG parameter for the Oracle clients on dev03 or our local machine was not set with this value. On setting NLS_LANG parameter to AMERICAN_AMERICA.UTF8 on client side, the issue got resolved.
     
    To set NLS_LANG on Windows check the following entry in the registry: HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE/NLS_LANG. On Unix NLS_LANG is set as a local environment variable.