column_Mysql_脚本之家

兴發国际娱乐手机登录,使用javabean出现以下错误, 66480555 [http-80-4] WARN
org.hibernate.util.JDBCExceptionReporter – SQL Error: 1366, SQLState:
HY000 66480555 [http-80-4] ERROR
org.hibernate.util.JDBCExceptionReporter – Incorrect string value:
‘\xE7\x89\xA9\xE8\xB5\x84…’ for column ‘search’ at row 1
org.hibernate.exception.GenericJDBCException: could not execute query at
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList at
org.hibernate.loader.Loader.listIgnoreQueryCache at
org.hibernate.loader.Loader.list at
org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289) at
org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1699) at
org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152) at
ceapet.jbpm.fileUploadBean.mRecordsList(fileUploadBean.java:313)
java.sql.SQLException: Incorrect string value:
‘\xE4\xBA\x8C\xE6\xAC\xA1…’ for column ‘search’ at row 1
不能使用中文进行搜索,但是insert into
中文是可以的。我的数据库和数据表中所有的charset都是设置的utf8。
我在Windows
xp下程序没有问题,但是在Linux下,同样的程序、同样的数据库就报错,百思不得其解。
网上搜了搜有很多关于此的问题,当然基本都是insert into
报错,基本都是建议set names gbk,或是把数据库删掉重新建。
但针对我的具体情况,应该不是上述原因。仔细考虑后,我的这个sql执行的是存储过程,是不是存储过程也应该和表一样有字符集的问题,果然,
存储过程的参数的字符集也应该设置。 复制代码 代码如下: CREATE
DEFINER=`root`@`localhost` PROCEDURE `ceapet_upload_proce`,IN
dir varchar,IN search varchar 问题就这样解决了!

java WEB 操作Mysql Hibernate
org.hibernate.exception.GenericJDBCException: Could not execute JDBC
batch update
at
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:254)
at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1001)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:339)
at
org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.baidu.test.test.main(test.java:38)
Caused by: java.sql.BatchUpdateException: Incorrect string value:
‘\xE5\x8C\x96\xE5\xAD\xA6’ for column ‘project’ at row 1
at
com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1269)
at
com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:955)
at
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:247)

… 8 more

代码出错

原因是因为我在hibernate.cfg.xml中 加入了-----------------------------------------------------------------------------<property name="connection.url"> jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf-8 </property> -----------------------------------------------------------------------------为什么要加入这段呢 因为我之前插入中文显示问号s.setProject; s.setScore; ss.setProject; 可是加入之后就出bug了 就算我把"物"换成 URLEncoder.encode("物", "utf-8");也不行 ------------------------------------------------------------------------ mysql status和show variables like '%char%'如下所示: mysql Ver 14.14 Distrib 5.6.24, for Win32 

Connection id: 2
Current database: test
Current user: root@localhost
SSL: Not in use
Using delimiter: ;
Server version: 5.6.24 MySQL Community Server
Protocol version: 10
Connection: localhost via TCP/IP
Server characterset: latin1
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
TCP port: 3306

发表评论

电子邮件地址不会被公开。 必填项已用*标注