香河做网站,wap网站制作怎么做,net开发网站建设,塑料模板多少钱一平方问题是这样的#xff0c;我在写一个网站#xff0c;打算使用连接池。我使用J2EE开发#xff0c;开始使用的是直连的方式#xff0c;附上代码public class ConnDb {private String getDriver com.mysql.jdbc.Driver;private String getUrl jdbc:mysql:/…问题是这样的我在写一个网站打算使用连接池。我使用J2EE开发开始使用的是直连的方式附上代码public class ConnDb {private String getDriver com.mysql.jdbc.Driver;private String getUrl jdbc:mysql://localhost:3306/itwork?useUnicodetruecharacterEncodingutf-8;private String getName root;private String getpwd ;static Connection con;static Statement stat;static ResultSet rs null;int i 0;//定义一个方法用于获得Connectionpublic Connection getConn(){try {Class.forName(getDriver);try {con DriverManager.getConnection(getUrl,getName,getpwd);} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();}} catch (ClassNotFoundException e) {System.out.println(找不到驱动);}return con;}// public Connection getConn(){// try{// Context ctx new InitialContext();// DataSource ds (DataSource)ctx.lookup(java:comp/env/jdbc/mysql);// Connection con ds.getConnection();// return con;// }catch(SQLException e){// e.printStackTrace();// }catch(NamingException e){// e.printStackTrace();// }// return null;// }后来考虑到并发访问就使用数据库连接池我在META-INF下建立了context.xml文件发代码?xml version1.0 encodingUTF-8?namejdbc/mysqlauthContainertypejavax.sql.DataSourcemaxActive100maxIdle30maxWait10000usernamerootpassworddriverClassNamecom.mysql.jdbc.Driverurljdbc:mysql://localhost:3306/itwork?autoReconnecttrue/请看一下我在上面发的java代码中注释的部分那是用来使用连接池来获取连接的。接下来就是我的问题了我在直连的代码中使用的Url中jdbc:mysql://localhost:3306/itwork?useUnicodetruecharacterEncodingutf-8指定了字符集编码而我在连接池中无法配置导致我在使用数据库连接池时出现中文乱码。请指导我如何在连接池中指定字符集PS我的数据库和界面以及Servlet中的编码都是UTF-8都是没有问题的。我使用直连也是没有乱码的就是连接池出问题