java.sql.SQLException: Unsupported character encoding 'utf8mb4'.

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS PostgreSQL,集群系列 2核4GB
简介: 版权声明:本文为 testcs_dn(微wx笑) 原创文章,非商用自由转载-保持署名-注明出处,谢谢。 https://blog.csdn.net/testcs_dn/article/details/76199827 四月 12, 2017 3:47:52 下午 org.
版权声明:本文为 testcs_dn(微wx笑) 原创文章,非商用自由转载-保持署名-注明出处,谢谢。 https://blog.csdn.net/testcs_dn/article/details/76199827

四月 12, 2017 3:47:52 下午 org.apache.catalina.core.StandardWrapperValve invoke

严重: Servlet.service() for servlet [SpringMVC] in context with path [/yuyi] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 

### Error updating database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Unsupported character encoding 'utf8mb4'.)

### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Unsupported character encoding 'utf8mb4'.)] with root cause

java.sql.SQLException: Unsupported character encoding 'utf8mb4'.

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1084)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:973)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:918)

at com.mysql.jdbc.StringUtils.getBytes(StringUtils.java:572)

at com.mysql.jdbc.StringUtils.getBytes(StringUtils.java:717)

at com.mysql.jdbc.Buffer.writeStringNoNull(Buffer.java:700)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2720)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2832)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2781)

at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1569)

at com.mysql.jdbc.ConnectionImpl.loadServerVariables(ConnectionImpl.java:4218)

at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3613)

at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2554)

at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2321)

at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:832)

at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)

at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:417)

at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:344)

at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)

at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)

at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)

at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221)

at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)

at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)

at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)

at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:81)

at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:67)

at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:279)

at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:72)

at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:47)

at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:105)

at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:71)

at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:152)

at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:141)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)

at com.sun.proxy.$Proxy13.insert(Unknown Source)

at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:240)

at com.wanyu.frame.base.BaseMyIbatisDao.save(BaseMyIbatisDao.java:198)

at com.wanyu.yuyi.dao.CommentDao.saveOrUpdate(CommentDao.java:29)

at com.wanyu.yuyi.dao.CommentDao.saveOrUpdate(CommentDao.java:1)

at com.wanyu.frame.base.BaseManager.saveOrUpdate(BaseManager.java:68)

at com.wanyu.yuyi.controller.CommentController.AddConment2(CommentController.java:274)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)

at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)

at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)

at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)

at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:690)

at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)

at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)

at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)

at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)

at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)

at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:509)

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1104)

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)

at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1524)

at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1480)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Thread.java:745)

问题原因:

产生这个问题的原因是为解决  表情的问题,尝试在JDBC连接字符串中指定编码,但是不支持。

解决方法:

参考:MySQL 解决 emoji表情 的方法,使用utf8mb4 字符集(4字节 UTF-8 Unicode 编码)

相关阅读

utf8mb4 字符集(4字节 UTF-8 Unicode 编码)

CentOS下安装MySQL,Windows下使用Navicat for MySql连接

MySQL学习(二)图形界面管理工具Navicat for MySQL安装和使用


相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
6月前
|
Java 编译器 ice
【Java开发指南 | 第十五篇】Java Character 类、String 类
【Java开发指南 | 第十五篇】Java Character 类、String 类
62 1
|
6月前
|
Java
学习一下Java中Character类的使用
学习一下Java中Character类的使用
68 0
|
2月前
|
Java 开发者
Java Character 类详解
Java中的`Character`类是`java.lang`包的一部分,用于将基本类型`char`封装为对象,并提供了丰富的静态方法来处理字符,如类型判断、大小写转换等。
|
2月前
|
Java
Java Character 类详解
`Character` 类是 Java 中的一个封装类,位于 `java.lang` 包中,主要用于处理单个字符。它是一个最终类,提供了多种静态方法来检查和操作字符属性,如判断字符是否为字母、数字或空格,以及转换字符的大小写等。此外,`Character` 类还支持自动装箱和拆箱,简化了 `char` 和 `Character` 之间的转换。以下是一些示例代码,展示了如何使用 `Character` 类的方法来检查字符属性和执行字符转换。掌握 `Character` 类的用法有助于更高效地处理字符数据。
解决异常 java.net.URISyntaxException: Illegal character in query at index
解决异常 java.net.URISyntaxException: Illegal character in query at index
864 0
|
Java 编译器 数据库连接
Cause java.sql.SQLDataException Unsupported conversion from LONG to java.sql.Timestamp
Cause java.sql.SQLDataException Unsupported conversion from LONG to java.sql.Timestamp
689 0
|
5月前
Exception in thread "main" java.lang.IllegalArgumentException: U+6570 ('.notdef') is not available in the font Helvetica-Bold, encoding: WinAnsiEncoding 这个问题如何解决
【6月更文挑战第19天】Exception in thread "main" java.lang.IllegalArgumentException: U+6570 ('.notdef') is not available in the font Helvetica-Bold, encoding: WinAnsiEncoding 这个问题如何解决
790 2
|
6月前
Exception in thread "main" java.lang.IllegalArgumentException: U+6570 ('.notdef') is not available in the font Helvetica-Bold, encoding: WinAnsiEncoding 问题解决
【5月更文挑战第26天】Exception in thread "main" java.lang.IllegalArgumentException: U+6570 ('.notdef') is not available in the font Helvetica-Bold, encoding: WinAnsiEncoding 问题解决
462 2
|
6月前
|
Java 编译器
Java Character 类
4月更文挑战第13天
java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must b
java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must b
248 0
下一篇
无影云桌面