补充一下,我的驱动是用的mysql-connector-java-3.1.7-bin.jar

解决方案 »

  1.   

    <%@ page contentType="text/html; charset=gb2312" errorPage="" %>
    <%@ page language="java" import="java.sql.*,java.util.*"%>
    <%
      try {
        Class.forName("com.mysql.jdbc.Driver").newInstance();
      }
      catch (Exception E) {
        out.println("Unable to load driver.");
      }  try {
        Connection C = DriverManager.getConnection("jdbc:mysql://localhost:3307/cnzx?user=root&password=iamcnzxserver&useUnicode=true&characterEncoding=GB2312");
        Statement s=C.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
        ResultSet rs = s.executeQuery("select * from bbsnote");
        if(rs.next()){
          String str = new String(rs.getString("notename").getBytes("ISO8859_1"), "GBK");
          out.println("note="+str);  
        }
      }
      catch (SQLException E) {
        out.println("SQLException: " + E.getMessage());
        out.println("SQLState: " + E.getSQLState());
        out.println("VendorError: " + E.getErrorCode());
      }
    %>
      

  2.   

    Mysql中的中文取出来后要进行编码转换才能显示的