java 读取 Excel 数据库中文乱码

[code="java"][/code]

  try
  {
   Class.forName(driverName);
   dbConn = DriverManager.getConnection(dbURL, "", "");
   Statement smt = dbConn.createStatement();
   ResultSet set = smt.executeQuery("select * from [sheet1$]");
  int i =0;
   while (set.next())
   {
    System.out.print(i + "\t") ; 
    String str1 = set.getString(1);
    String str2 = set.getString(2);
    String str3 = set.getString(3);
    if (str1 != null){
         System.out.print(new String(str1.getBytes("ISO-8859-1") ,"gbk") + "\t") ; 
    }

    if (str2 != null){
         System.out.print(new String(str2.getBytes("ISO-8859-1") ,"utf-8") + "\t") ; 
    }

    if (str3 != null){
         System.out.println(new String(str3.getBytes("ISO-8859-1") ,"gb2312") + "\t") ; 
    }

    i ++;
   }
  } catch (ClassNotFoundException e)
  {
   e.printStackTrace();
  } catch (SQLException e)
  {
   e.printStackTrace();
  } finally
  {

[img]http://dl2.iteye.com/upload/attachment/0088/0295/95b4bfef-bd6a-38bd-a108-734d678d064e.gif[/img]

中文乱码,求解药 [code="java"][flash=200,200][img][/img][/flash][/code]

查看全部
TreasureNow
李树超
2013/08/09 16:16
  • it技术
  • 互联网问答
  • IT行业问题
  • 编程语言问答
  • 计算机技术
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

0个回复