Hi all,
Thank you for all your replies. Here is my code...
**************************************************
import java.sql.*;
import java.io.*;
import java.util.*;
public class StreamConverter {
static void writeOutput(byte[] str) {
try {
FileOutputStream fos = new FileOutputStream("test.txt");
Writer out = new OutputStreamWriter(fos, "UTF-8");
fos.write(str);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (java.lang.ClassNotFoundException e)
{
System.out.println("Rosak - tak jumpa class(jdbc driver): " + e.getMessage());
}
// Open the datasource
try
{
Properties prop = new java.util.Properties();
prop.put("useUnicode", "true");
prop.put("characterEncoding", "UTF-8");
String url = "jdbc:odbc:cina";
Connection con = DriverManager.getConnection(url, prop);
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rec = stmt.executeQuery ("SELECT * FROM Test");
while(rec.next()) {
String xx = new String(rec.getString("question"));
byte ucode[] = xx.getBytes("UTF-8");
System.out.println("This is byte ucode: "+ucode);
String Display = new String(ucode, "UTF-8");
writeOutput(ucode);
}
stmt.close();
} catch (SQLException s) {
System.out.println("Error s DBase --> " + s.toString() + " " + s.getErrorCode() + " " + s.getSQLState());
}catch (Exception e) {
System.out.println("Error e DBase -->" + e.toString() + e.getMessage());
}
}
}
**************************************************
Can anyone please.... tell me what's wrong with it....
I thank you in advance.
[ December 25, 2002: Message edited by: Ahmad Safri ]