今天开发项目时遇到一个问题,并没有使用存储过程来批量执行SQL语句。而是在Java业务处理过程中将.sql文件中的批量SQL语句分条读取,读取后一条一条执行。原先的.sql文件是使用SQL Manager导出的,需要在项目部署的时候将导出的.sql文件重新部署到新的客户端电脑上,所以需要进行批量执行SQL语句的操作。好进入正题:
在批量执行的过程中遇到Variable 'character_set_client' can't be set to the value of Null的SQL,JDBC的异常。经过长时间排查,排除了数据库数据集的设置问题,排除了SQL语句的格式问题。最后发现是使用SQL Manager导出的.sql文件中有SQL语句的注释,原来是这些注释文件造成以上的报错。所以在执行类似的操作时,以后要记得删除注释语句后再执行批量SQL语句操作。
# SQL Manager 2007 Lite for MySQL 4.0.5.1
# ---------------------------------------
# Host : localhost
# Port : 3306
# Database : image
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
#
# Structure for the `imagefeatures1` table :
#
这些都要删除掉,当然也可能是跟我使用的Java读取语句有关系。Mark下,以后不要犯同样的问题了。花了我大概一个小时时间找这个问题,伤不起啊!
分享到:
相关推荐
其中`character_set_client`和`character_set_connection`是确定客户端连接时使用的字符集的重要变量。 - **更改客户端连接的字符集**: ```sql SET NAMES utf8; ``` 或者分别设置: ```sql SET character_...
| Variable_name | Value | +--------------------------+--------------------------+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | latin1 | | ...
| Variable_name | Value | +--------------------------+-------------------------------------+ | character_set_client | utf8 | --客户端字符集 | character_set_connection | utf8 | | character_set_...
Causes the next filter in the chain to be invoked, or if the calling filter is the last filter in the chain, causes the resource at the end of the chain to be invoked. doFilter(ServletRequest, ...
- 上述结果中,重点关注`character_set_client`和`character_set_results`,这些设置可以通过`SET NAMES utf8`或`SET NAMES gbk`等方式进行更改。 2. **查看特定数据库的编码格式**: - 使用`SHOW CREATE ...
When in the smb.conf (of Samba 2.x) there hasn't been set a correct "character set" variable, files which are created from Win* clients are being created in the client's codepage, e.g. cp850 for ...
seems that some servers can‘t deglut the info too fast, causing problems with sockets buffers and leading to crash the client machine, I don‘t know if is a Borland bug or Microsoft bug. (thanks to ...
Changes to the Handling of Deprecation Warnings Python 3.1 Features PEP 372: Adding an Ordered Dictionary to collections PEP 378: Format Specifier for Thousands Separator PEP 389: The argparse ...
5.12 The Null Value as an Expression . . . . . . . . . . . . . . . . . . . . . . 114 5.13 The Compound Scalar Expression . . . . . . . . . . . . . . . . . . . . 115 5.14 The Aggregation Function and ...