NutzCN Logo
问答 关于数据库编码问题-是数据库版本的问题?
发布于 2596天前 作者 Rekoe 1681 次浏览 复制 上一个帖子 下一个帖子
标签:

现在数据库版本

mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.19    |
+-----------+
1 row in set (0.00 sec)

标结构已经是 utf8mb4

CREATE TABLE `dump_data` (
  `id` varchar(128) NOT NULL,
  `res_id` varchar(128) DEFAULT NULL,
  `push_time` bigint(64) DEFAULT NULL,
  `converted` bigint(64) DEFAULT NULL COMMENT '打开推送',
  `successful` bigint(64) DEFAULT NULL COMMENT '收到推送',
  `title` varchar(128) DEFAULT NULL,
  `is_modify` tinyint(1) DEFAULT NULL,
  `category` varchar(128) DEFAULT NULL,
  `area` varchar(128) DEFAULT NULL,
  `ct` datetime DEFAULT NULL,
  `ut` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

但数据插入还是错误

INSERT INTO dump_data(id,res_id,push_time,converted,successful,title,is_modify,category,area,ct,ut) VALUES(?,?,?,?,?,?,?,?,?,?,?) 
    |                                    1 |      2 |             3 |   4 |    5 |                                              6 |     7 | 8 | 9 |                  10 |                  11 |
    |--------------------------------------|--------|---------------|-----|------|------------------------------------------------|-------|--|--|---------------------|---------------------|
    | beaf271e-8c8a-4a24-adbe-d1daa195c9fe | 376766 | 1510505754000 | 354 | 7827 | 😠عاجل.. ضربة قوية لمنتخب مصر في مباراة غانا

 | false |  |  | 2017-11-13 11:28:44 | 2017-11-13 11:28:44 |
  For example:> "INSERT INTO dump_data(id,res_id,push_time,converted,successful,title,is_modify,category,area,ct,ut) VALUES('beaf271e-8c8a-4a24-adbe-d1daa195c9fe','376766',1510505754000,354,7827,'😠عاجل.. ضربة قوية لمنتخب مصر في مباراة غانا

',false,'','','2017-11-13 11:28:44','2017-11-13 11:28:44') "
[11:28:44:367] [DEBUG] - org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:97) - SQLException
java.sql.SQLException: Incorrect string value: '\xF0\x9F\x91\x8D\xD9\x86...' for column 'title' at row 1
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964) ~[mysql-connector-java-5.1.40.jar:5.1.40]
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3970) ~[mysql-connector-java-5.1.40.jar:5.1.40]
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3906) ~[mysql-connector-java-5.1.40.jar:5.1.40]
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2524) ~[mysql-connector-java-5.1.40.jar:5.1.40]
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2677) ~[mysql-connector-java-5.1.40.jar:5.1.40]
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2549) ~[mysql-connector-java-5.1.40.jar:5.1.40]
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861) ~[mysql-connector-java-5.1.40.jar:5.1.40]
	at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1192) ~[mysql-connector-java-5.1.40.jar:5.1.40]
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2931) ~[druid-1.0.29.jar:1.0.29]
	at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440) ~[druid-1.0.29.jar:1.0.29]
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2929) ~[druid-1.0.29.jar:1.0.29]
	at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:131) ~[druid-1.0.29.jar:1.0.29]
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:493) ~[druid-1.0.29.jar:1.0.29]
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:308) ~[nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:90) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.plugins.cache.dao.DaoCacheInterceptor._exec(DaoCacheInterceptor.java:28) [nutz-plugins-daocache-1.r.63-SNAPSHOT.jar:?]
	at org.nutz.plugins.cache.dao.CachedNutDaoExecutor.exec(CachedNutDaoExecutor.java:188) [nutz-plugins-daocache-1.r.63-SNAPSHOT.jar:?]
	at org.nutz.plugins.cache.dao.DaoCacheInterceptor.filter(DaoCacheInterceptor.java:18) [nutz-plugins-daocache-1.r.63-SNAPSHOT.jar:?]
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithTransaction(NutDaoRunner.java:104) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:88) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.dao.impl.sql.run.NutDaoRunner$1.run(NutDaoRunner.java:74) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.trans.Trans.exec(Trans.java:174) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:72) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:240) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:252) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:55) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.dao.impl.NutDao.insert(NutDao.java:149) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.dao.impl.NutDao.insert(NutDao.java:155) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.dao.impl.NutDao.insertOrUpdate(NutDao.java:1079) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at com.mysada.module.OnesignalModule.fetch(OnesignalModule.java:483) [classes/:?]
	at com.mysada.module.OnesignalModule$$NUTZAOP._aop_invoke(OnesignalModule.java:1) [nutz-1.r.63-SNAPSHOT.jar:?]
	at org.nutz.aop.InterceptorChain.invoke(InterceptorChain.java:77) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.aop.InterceptorChain.doChain(InterceptorChain.java:57) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at org.nutz.aop.interceptor.async._async_task.call(AsyncMethodInterceptor.java:43) [nutz-1.r.63-SNAPSHOT.jar:1.r.63-SNAPSHOT]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_144]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_144]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_144]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_144]
7 回复

驱动版本对吗?

这个版本的

    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.40</version>
      <scope>compile</scope>
    </dependency>

额,不加表情就能插入?项目的编码对吗?

CHARSET=utf8mb4 ?

@zozoh 是的
@wendal 我差下项目编码

Default Charset : UTF-8

额,是不是jdbc url里面约束了编码信息?

添加回复
请先登陆
回到顶部