mysql 数据库中varbinary 字段如何更新 如题,数据存储为varbinary 更新时直接用一个数组当参数但是更新不进去,哪位给个明示 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个存储二进制字符串mysql> desc vartest;+-------+----------------+------+-----+---------+-------+| Field | Type | Null | Key | Default | Extra |+-------+----------------+------+-----+---------+-------+| blob1 | varbinary(100) | NO | | | |+-------+----------------+------+-----+---------+-------+1 row in set (0.00 sec)mysql> select md5('mysql');+----------------------------------+| md5('mysql') |+----------------------------------+| 81c3b080dad537de7e10e0987a4bf52e |+----------------------------------+1 row in set (0.00 sec)mysql> select blob1,hex(blob1) from vartest;Empty set (0.00 sec)mysql> insert into vartest values(unhex(md5('mysql')));Query OK, 1 row affected (0.05 sec)mysql> select blob1,hex(blob1) from vartest;+------------------+----------------------------------+| blob1 | hex(blob1) |+------------------+----------------------------------+| 伱皜谡7迆鄻zK? | 81C3B080DAD537DE7E10E0987A4BF52E |+------------------+----------------------------------+1 row in set (0.00 sec) 这样单纯的插入数据库是没问题,但是在程序中使用了。String str="testInsert";byte[] tempByte = new byte[str.getBytes("utf-8").length];PreparedStatement stmt = conn.prepareStatement("insert into tx(others) values(?)");stmt.setBytes(1, tempByte);stmt.execute();stmt.close();这样输入就会出问题。不能把正确的数据写入到数据库中 上面 有一句赋值没用弄上去System.arraycopy(str.getBytes("utf-8"), 0, tempByte, 0, str.getBytes("utf-8").length); Undefine reference to 'my_progname' MYSQL 提供的C语言API不接受汉字,怎么办 在一个表中多个条件合并查询 请问mysql root root是一条什么命令 mysql写触发器的疑问 pg 提问 , 我想把 每条数据里 的 每个字段内容 全角,或者半角里的空格去掉,我该则么做?(急) MSSQL数据导出到MYSQL时出现BLOB值错误!在线等 MYSQL 时间不正常 高手看一下哦 两个表联合查询,有记录无法查询出来 Mysql sql语句优化问题 求一段mysql建库建表语句,要有表关联的语句 SQL问题..
mysql> desc vartest;
+-------+----------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------------+------+-----+---------+-------+
| blob1 | varbinary(100) | NO | | | |
+-------+----------------+------+-----+---------+-------+
1 row in set (0.00 sec)mysql> select md5('mysql');
+----------------------------------+
| md5('mysql') |
+----------------------------------+
| 81c3b080dad537de7e10e0987a4bf52e |
+----------------------------------+
1 row in set (0.00 sec)mysql> select blob1,hex(blob1) from vartest;
Empty set (0.00 sec)mysql> insert into vartest values(unhex(md5('mysql')));
Query OK, 1 row affected (0.05 sec)mysql> select blob1,hex(blob1) from vartest;
+------------------+----------------------------------+
| blob1 | hex(blob1) |
+------------------+----------------------------------+
| 伱皜谡7迆鄻zK? | 81C3B080DAD537DE7E10E0987A4BF52E |
+------------------+----------------------------------+
1 row in set (0.00 sec)
String str="testInsert";
byte[] tempByte = new byte[str.getBytes("utf-8").length];
PreparedStatement stmt = conn.prepareStatement("insert into tx(others) values(?)");
stmt.setBytes(1, tempByte);
stmt.execute();
stmt.close();
这样输入就会出问题。不能把正确的数据写入到数据库中
System.arraycopy(str.getBytes("utf-8"), 0, tempByte, 0, str.getBytes("utf-8").length);