如何使用Java字节在Oracle中插入泰语?
我尝试使用UTF-8,但我无法用Java对其他语言进行编码和解码 请给我一些关于如何使用UTF-8编码的想法如何使用Java字节在Oracle中插入泰语?,java,oracle,Java,Oracle,我尝试使用UTF-8,但我无法用Java对其他语言进行编码和解码 请给我一些关于如何使用UTF-8编码的想法 字符串,插入到Oracle并将其取回?Oracle DB能够在其表中存储多种语言。为此,我们必须选择正确的字符集 您可能面临以下问题: 输入数据的客户端的NLS配置未正确配置 检索数据的客户端的NLS配置未正确配置 泰语字符集中的一个泰语字符需要UTF8或AL32UTF8中的3个字节 这对你有帮助 Connection con = null; String url = "jdbc:ora
字符串,插入到Oracle并将其取回?Oracle DB能够在其表中存储多种语言。为此,我们必须选择正确的字符集 您可能面临以下问题:
Connection con = null;
String url = "jdbc:oracle:thin:@//localhost:1521/xe";
String driver = "oracle.jdbc.OracleDriver";
String s = "สวัสดี";
System.out.println("Thai hello :" + s);
String temp = s.getBytes() + "";
String temp2 = new String(s.getBytes());
System.out.println("Thai temp bytes :" + temp);
System.out.println("Thai temp2 bytes :" + temp2);
try {
Class.forName(driver);
con = DriverManager.getConnection(url, "system", "xxxxx");
try {
PreparedStatement st = con.prepareStatement("INSERT into encodeleo VALUES(?)");
st.setBytes(1, s.getBytes());
st.executeUpdate();
String temp1;
ResultSet rs = st.executeQuery("select name from encodeleo");
rs.next();
temp1 = new String(rs.getBytes("name"));
System.out.println("temp1 :" + temp1);
System.out.println("1 row affected");
} catch (SQLException se) {
se.printStackTrace();
System.out.println("SQL statement is not executed!");
}
} catch (Exception e) {
e.printStackTrace();
}
更多信息
及
NLS_LANG=THAI_THAILAND.TH8TISASCII;