class Employee
{
public static void main (String args [])
throws SQLException
{
Properties p = new Properties();
p.put("user","system");
p.put("password","manager");
// p.put("CHARSET","utf8");
p.put("CHARSET","GBK");
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Connect to the database
// You can put a database name after the @ sign in the connection URL.
Connection conn =
DriverManager.getConnection ("jdbc:oracle:oci8:@sun", p);
// Create a Statement
Statement stmt = conn.createStatement ();
ResultSet rset = stmt.executeQuery ("select * from users");
// int oracleID= CharacterSet.ZHS16GBK_CHARSET;
// CharacterSet gb= CharacterSet.make(oracleID);
// Iterate through the result and print the employee names
// oracle.sql.CHAR ss;
String ss1;
String ss;
while (rset.next ())
{
// ss=new oracle.sql.CHAR(rset.getString(2),gb);
ss=rset.getString(2);
try{
byte[] b=ss.getBytes();
ss1= new String(b,"GBK");
System.out.println(ss1);
}catch(Exception e){
// return(e.getMessage());
}
}
// Close the RseultSet
rset.close();
// Close the Statement
stmt.close();
// Close the connection
conn.close();
}
public Employee() {}
}