request.setCharacterEncoding("gb2312")

解决方案 »

  1.   

    request.setCharacterEncoding("gb2312")
    这个不行,试过了,jdbc指定为GBK是什么意思?
      

  2.   

    ResultSet rs = stmt.executeQuery("select username '用户名',password '密码',usertype '用户类别' from t_user order by id desc");        ======>>>>>>>>>>>ResultSet rs = stmt.executeQuery("select username  as '用户名',password  as '密码',usertype as '用户类别' from t_user order by id desc");        
      

  3.   

    jdbc:mysql://localhost:3306/saker?useUnicode=true&characterEncoding=gb2312
    就好了,谢谢各位!
      

  4.   

    http://dev.csdn.net/article/33/33647.shtmimport java.sql.*;
    import com.redv.sql.encoding.*;Class.forName("org.gjt.mm.mysql.Driver");
    Connection con = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
      con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "");
      //接管数据库连接实例
      boolean coding = true;
      EncodingConnection codingConnection = new EncodingConnection(con, coding, "ISO-8859-1", "GBK");
      //获得接管后的数据库连接实例,以后直接使用con已经是经过EncodingConnection重新包装过的实例
      con = codingConnection.getConnection();
      pstmt = con.prepareStatement("SELECT f3, f4 FROM tbl1 WHERE f1 = ? AND f2 = ?");
      pstmt.setString(1, f1);
      pstmt.setString(2, f2);
      rs = pstmt.executeQuery();
      String f3, f4;
      while(rs.next()) {
        f3 = rs.getString(1);
        f4 = rs.getString(2);
      }
    }
    finally {
      //close resouces
      ...
    }