我写了个mysql保存文件的例子。。
结果,给我这样一句错误信息:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'cl|??u×??\"a?!?\0??>?TH°>?V?ìF^é????? $?c^fSí k??é?t\'”??5<4?9B?ü?E6?—W?' at line 1我在保存图片和zip文件的时候会出现这种现象。。怎么会是哦??
结果,给我这样一句错误信息:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'cl|??u×??\"a?!?\0??>?TH°>?V?ìF^é????? $?c^fSí k??é?t\'”??5<4?9B?ü?E6?—W?' at line 1我在保存图片和zip文件的时候会出现这种现象。。怎么会是哦??
| Field | Type | Null | Key | Default | Extra |
+----------+------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| filedata | mediumblob | NO | | NULL | |
| filesize | int(11) | NO | | NULL | |
+----------+------------+------+-----+---------+----------------+
额,,我把我的代贴出来算了。
try {
Class.forName("org.gjt.mm.mysql.Driver");
conn = DriverManager
.getConnection("jdbc:mysql://localhost:3306/mytest?user=root&password=8868829xgj");
pstat = conn.prepareStatement(sql);
pstat.setBinaryStream(1, fileItem.getInputStream(), (int) fileItem
.getSize());
pstat.setInt(2, (int) fileItem.getSize());
pstat.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
flag = "<h3 style='color:red'>SQL错误</h3><br>";
} catch (IOException e) {
e.printStackTrace();
flag = "<h3 style='color:red'>IO错误</h3><br>";
} catch (ClassNotFoundException e) {
e.printStackTrace();
}