"䶮"字的显示问题
系统环境:
Oracle 10.2 字符集SIMPLIFIED CHINESE_CHINA.ZHS16GBK
jvm 字符集:GBK
该程序在SUN的JRE下运行正常,在IBM JRE下运行结果不正确“䶮”显示为“?”
/** * Create on 2010-7-14 * Copyright 2009 startech. All rights reserved. */package com;import java.nio.charset.Charset;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.Statement;/** * @author lb * */public class TestJdbc {/*** @param args*/public static void main(String[] args) {TestJdbc test = new TestJdbc();try {test.testJdbc();} catch (Exception e) {e.printStackTrace();}}private void testJdbc() throws Exception {Class.forName("oracle.jdbc.driver.OracleDriver");String url = "jdbc:oracle:thin:@10.40.0.15:1521:sxyldev";Connection connection = DriverManager.getConnection(url, "cp3test","cp3test");Statement statement = connection.createStatement();ResultSet resultSet = statement.executeQuery("select name from users where id = '1010900166'");while (resultSet.next()) {String nameString = resultSet.getString("name");System.out.println(nameString);byte[] bytes = nameString.getBytes();for (byte b : bytes) {System.out.print(b);}System.out.println();}System.out.println("当前JVM的默认字符集:" + Charset.defaultCharset());}}