Dear Ranchers, I'm using Java Swing with MySQL as the database for developing a Human Resource application. In a particular point i want to insert the photograph of the employees in to the system. From my friends i heard, we can use BLOG for inserting images into the system.
Can any one please send me the sample code for inserting the image into the database and retrieving the image from the database.
I think your buddy probably said "blob," not "blog." A blob is a database column type that represents an arbitrary sequence of bits which the developer can interprit as s/he pleases ... in your case, the blob will be interpreted as an image.
Here's a good article that describes using java to read/write image blobs to a mysql database. article
Besides the declartion of import of the java.io.* package which causes the errors you show us there are some other hints for you in order to let the code work. For a form to upload a file you should specify an enctype attribute on the form element with the value multipart/form-data. Also for handling the uploaded data in the right way (now you only read the first byte of the stream) look at a package like FileUpload from apache commons (http://jakarta.apache.org/commons/fileupload/). And please use a finaly block to close the connection.