当前位置: 代码迷 >> Java Web开发 >> mysql编码有关问题
  详细解决方案

mysql编码有关问题

热度:284   发布时间:2016-04-17 10:46:53.0
mysql编码问题
XML code
    <property name="url">            <value>jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf-8            </value>        </property>


页面出错信息:java.sql.SQLException: Unsupported character encoding 'utf-8
'.
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
com.mysql.jdbc.StringUtils.getBytes(StringUtils.java:541)
com.mysql.jdbc.StringUtils.getBytes(StringUtils.java:685)
com.mysql.jdbc.Buffer.writeStringNoNull(Buffer.java:664)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2094)
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2620)
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2570)
com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1476)
com.mysql.jdbc.ConnectionImpl.loadServerVariables(ConnectionImpl.java:3888)
com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3431)
com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2386)
com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163)
com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)
com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378)
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:83)
org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:184)
org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:840)
org.apache.commons.dbcp.AbandonedObjectPool.borrowObject(AbandonedObjectPool.java:117)
org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:110)
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:312)
org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:113)
org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:210)
$Proxy6.toString(Unknown Source)
java.lang.String.valueOf(String.java:2827)
java.lang.StringBuffer.append(StringBuffer.java:219)
org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:194)
org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:249)
org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:296)
com.gogoosoft.dao.impl.PersonDaoImp.getAll(PersonDaoImp.java:18)
com.gogoosoft.action.LoginAction.execute(LoginAction.java:36)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
  相关解决方案