Oracle JDBC and Oracle CHAR data type

后端 未结 5 1984
别跟我提以往
别跟我提以往 2020-11-29 12:03

I have a tricky issue with the Oracle JDBC driver\'s handling of CHAR data types. Let\'s take this simple table:



        
5条回答
  •  难免孤独
    2020-11-29 12:44

    I have nice fix for this. You have to add one property while getting connection from database.

    NLS_LANG=american_america.AL32UTF8
    

    or in Java connection you can use below code:

    java.util.Properties info = new java.util.Properties();
    info.put ("user", user);
    info.put ("password",password);
    info.put("fixedString","TRUE");
    info.put("NLS_LANG","american_america.AL32UTF8");
    info.put("SetBigStringTryClob","TRUE");
    String url="jdbc:oracle:thin:@"+serverName;
    log.debug("url="+url);
    log.debug("info="+info);
    Class.forName("oracle.jdbc.OracleDriver");
    conn  = DriverManager.getConnection(url,info);
    

提交回复
热议问题