This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I'm attempting to write a procedure to take a .gif file and store it in my MySQL database. So, in order, this is what happens: 1) user selects which file to save. 2) I take that file selection, store it locally on the web server. 3) Create a FileInputStream object based on the File object in (2). 4) Call my DAO with the FileInputStream where I insert the gif file using the PreparedStatement.setBinaryStream method.
When I run this code (below), I get the following error: 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 '(inv_id, caption, inv_image) values (63,'test',_binary'����\0JFIF\0\0\0d\0d\0' at line 1
Code snippets are below:
This code snippet takes the request object and parses out the parameters for the DAO call (one of which is the file itself).
Here's the code in my DAO:
I can verify that the file is valid and stored properly locally on the web server, so I know the chained File to the FileInputStream object is valid and is not null.