不好意思啊
少写了点东西少了个=true
<parameter>
      <name>url</name>
      <value>jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=gb2312</value>
</parameter>但是问题没有解决啊
Tomcat还是报错
高手帮忙看一下

解决方案 »

  1.   

    是不是在server.xml的url不能有&符号啊一有这个就报错
      

  2.   

    我现在用UTF-8还是不成下面是全部的东西这个是TestDBCP.jsp
    <%@ page contentType="text/html; charset=UTF-8"%>
    <%@ page import="java.sql.*"%>
    <%@ page import="javax.sql.*"%>
    <%@ page import="javax.naming.*"%>
    <%
    long start=System.currentTimeMillis();
    Context initContext = new InitialContext();
    Context envContext  = (Context)initContext.lookup("java:/comp/env");
    DataSource ds = (DataSource)envContext.lookup("jdbc/TestDBCP");
    Connection conn = ds.getConnection();
    Statement stmt = conn.createStatement();
    String strSql="insert into tbl_test (name) values ('中文')";
    stmt.executeUpdate(strSql);
    strSql = " select id,name from tbl_test ";
    ResultSet rs = stmt.executeQuery(strSql);
    while(rs.next())
    {
    out.println(rs.getString(1));
    out.println(rs.getString(2)+"<br>");
    }
    out.println(System.currentTimeMillis()-start);
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
    中文
    </body>
    </html>保存成UTF-8格式下面是web.xml添加的
      <resource-ref>
          <description>DB Connection</description>
          <res-ref-name>jdbc/TestDBCP</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
      </resource-ref>下面是server.xml里的
    <parameter>
       <name>url</name>
       <value>jdbc:mysql://localhost:3306/test</value>
    </parameter>下面是MySql里的
    CREATE TABLE `test`.`tbl_test` (
      `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
      `name` VARCHAR(45) NOT NULL
    )
    CHARACTER SET utf8;但是还是不行啊,都是乱码,为什么
      

  3.   

    在server.xml中的jdbc url中的"&"符号应该用转义字符如下:
    jdbc:mysql://localhost/test?useUnicode=true&amp;characterEncoding=gb2312