简体   繁体   English

mysql 5.5无效的转义序列java

[英]mysql 5.5 invalid escape sequence java

static byte[] ac = {'\\', '\'', '{', '}', '{'}; //not OK insert into tt values('\\\'{}{')
static byte[] ac = {'\\', '\'', '{', '}'}; //OK insert into tt values('\\\'{}')
static byte[] ac = {'\\', '\'', '{'}; //OK insert into tt values('\\\'{')
static byte[] ac = {'\'', '{', '}', '{'}; //OK insert into tt values('\'{}{')
static byte[] ac = {'\\', '{', '}', '{'}; //OK insert into tt values('\\{}{')
  • Ubuntu system Ubuntu系统
  • MySQL 5.5 MySQL 5.5
  • MySQL JDBC 5.1.22 MySQL JDBC 5.1.22

I am not able to insert 5 bytes to a blob table field, the bytes are shown above. 我无法在blob表字段中插入5个字节,字节如上所示。 The datasource connection encoding is set to UTF-8 . 数据源连接编码设置为UTF-8

Relevant information: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html 相关信息: http//dev.mysql.com/doc/refman/5.5/en/string-literals.html

Any idea why {} is so special? 知道为什么{}如此特别吗? it works with workbench. 它适用于工作台。

For the not ok, i got the following exception: 对于不好,我有以下例外:

java.sql.SQLException: Not a valid escape sequence: {')

This is a bug in some versions of MySQL's JDBC client (Connector/J); 这是MySQL的JDBC客户端(Connector / J)的某些版本中的错误; see http://bugs.mysql.com/bug.php?id=31457 (and other bugs linked from there). 请参阅http://bugs.mysql.com/bug.php?id=31457 (以及其他链接的其他错误)。 You should be able to fix it by upgrading to the latest Connector/J; 您应该能够通过升级到最新的Connector / J来修复它; alternatively, you can work around it by disabling escape-processing (by writing Statement.setEscapeProcessing(false) ). 或者,您可以通过禁用转义处理(通过编写Statement.setEscapeProcessing(false) )来解决它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM