This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm trying to insert an .exe file into mysql blob field in the database. I;ve tried to both ways i.e LOAD_FILE method and FileInputStream method at the local and remote Database server,
but it is consistently giving an error.The stacktrace of the error is : :
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 'binary) values('abc','19541a2746e08a6b8f5145bdbaa23e45','http:jadhjkhdf/dasdas',' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
The code i'm using is given below :
Please help me in resolving this issue. I guess my code is all correct and there is some ado with the Mysql version.
The current mysql version shown by my RHEL machin is :
mysql Ver 14.12 Distrib 5.0.22, for redhat-linux-gnu (i686) using readline 5.0
I have no experience with MySQL, but according to its documentationbinary is a reserved word.
You should escape the column name (probably enclosing it in back quotes), though changing the column name to something which is not a reserved word would be much better in the long run.
Joined: Feb 24, 2010
Thanks Mr. Martin.
My problem has been resolved. i already knew that Binary is a keyword but never thought that it would affect column names too.. i thought it's scope is upto Table names only. Well , it's not a problme any more as i've renamed the column and my code is working fine now. Thank you very much for the guidance