Guest User

Untitled

a guest
Mar 5th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. stmt.setString(1, "a"); // This won't return any records
  2.  
  3. conn.prepareStatement("select * from x where c = cast(? as char(4))")
  4.  
  5. String sql = "select * from x where c = ?";
  6. OraclePreparedStatement stmt = (OraclePreparedStatement) conn.prepareStatement(sql);
  7. stmt.setFixedCHAR(1, "a");
  8. ...
  9.  
  10. I have nice fix for this.You have to add one property while getting connection from database.
  11.  
  12. NLS_LANG=american_america.AL32UTF8
  13.  
  14. or
  15.  
  16. In Java connection you can use below code :
  17.  
  18. java.util.Properties info = new java.util.Properties();
  19. info.put ("user", user);
  20. info.put ("password",password);
  21. info.put("fixedString","TRUE");
  22. info.put("NLS_LANG","american_america.AL32UTF8");
  23. info.put("SetBigStringTryClob","TRUE");
  24. String url="jdbc:oracle:thin:@"+serverName;
  25. log.debug("url="+url);
  26. log.debug("info="+info);
  27. Class.forName("oracle.jdbc.OracleDriver");
  28. conn = DriverManager.getConnection(url,info);
  29.  
  30.  
  31. Thanks,
  32. Swapna
Add Comment
Please, Sign In to add comment