更新查询中的异常 [英] exception in update query
问题描述
我想在mysql表中将一个文件更新为Blob fileld,我试过这种方式
I want to update one file to a Blob fileld in mysql table, and I tried this way
String sqlUpdateXSLT = "UPDATE mailer_details.auto_mailer_2 set xslt=? where auto_mailer_name='" + mailerName + "'";
PreparedStatement stmt = con.prepareStatement(sqlUpdateXSLT);
FileInputStream fis = new FileInputStream(mFile);
stmt.setBlob(1, fis, (int) mFile.length());
int ra = stmt.executeUpdate(sqlUpdateXSLT);
但我得到了一个例外,例如:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:你的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在''附近使用正确的语法?其中auto_mailer_name =''atm4''''在第1行
这有什么问题?
我以类似的方式执行插入操作,没有问题。
but I got an exception such as:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 ''? where auto_mailer_name=''atm4'''' at line 1
What is problem this?
I performed insert operation similar way, and there were no problem.
推荐答案
参见 http://dev.mysql.com/doc/refman/5.5/en/update.html [ ^ ], SET
子句中的值看似不正确。
See http://dev.mysql.com/doc/refman/5.5/en/update.html[^], the value in your SET
clause does not appear correct.
int ra = stmt.executeUpdate();
而不是
instead
int ra = stmt.executeUpdate(sqlUpdateXSLT);
这篇关于更新查询中的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!