Click here to Skip to main content
16,015,218 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to update one file to a Blob fileld in mysql table, and I tried this way

Java
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);


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.
Posted
Updated 25-Mar-13 4:14am
v3

See http://dev.mysql.com/doc/refman/5.5/en/update.html[^], the value in your SET clause does not appear correct.
 
Share this answer
 
Java
int ra = stmt.executeUpdate();


instead

Java
int ra = stmt.executeUpdate(sqlUpdateXSLT);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900