on 11-18-2008 12:30 PM
I am working on Internationalization of application. I have a requirement to read the Japanese and Chinese characters from Excel sheet and save in Database table. The Microsoft Excel driver is not supporting the multibyte characters. The code snippet is
Connection conn = null;
String infile="ChinJap.xls";
String tabSheet = "multibyte";
try {
Properties info = new Properties();
info.put("charSet", "utf-8");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DriverID=22;READONLY=false;"+ "DBQ=" + infile,info)";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select English,Japanese,Chinese from [" + tabSheet+ "$]");
FileOutputStream fos=new FileOutputStream("temp.txt");
if(rs.next()){
do{
String temp = rs.getString(2)+"\n";
fos.write(temp.getBytes());
}while(rs.next());
}
The above code is not displaying Japanese and Chinese characters after reading from the Excel sheet that has the Japanse and chinese data in a sheet.
Any help in this regard is appreciated.
Thanks in advance
Hello,
first of all: What means doesn`t read - is there no output - unexcpected output ...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I mean , Using Statement object when I execute the query, it is executing and returning me the result. The result is saved to temp.txt, the temp.txt is opened in EDITPRO, but it is displaying only ????(question marks) instead of Japanese and Chinese characters.
I require, how to set the encoding or charcterset to excel driver so that it reads properly and saves the multibyte characters as they were in Excel.
Let me know if this clears doubt or I need to give more information to answer my question.
Your help is appreciated.
Thanks
Phani
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.