File file = new File("C:\\Users\\admin\\Desktop\\server\\flower1.jpg");
FileInputStream fs = new FileInputStream(file);
PreparedStatement ps = conn.prepareStatement("insert into picprop(picname,picsize,pictype,image) values(?,?,?,?)");
ps.setString(1,"yellow");
ps.setInt(2,89);
ps.setString(3,"jpeg");
ps.setBinaryStream(4,(InputStream)fs,(int)(file.length()));
int i=ps.executeUpdate();;
pw.println("value of i is:"+i);
The statement[ps.setBinaryStream(4,(InputStream)fs,(int)(file.length()));] is not getting executed. what night be the reason?
Please post your code within code tags.
What's the error you get? When you ask something you must tell us what is your problem and what you are attempting to do. We're not psychics
I think syntactically you piece of code is right, so give us more information about the error.
By the way, even though it is not an error it is not necessary to cast fs to InputStream. fs it's already and InputStream for being a FileInputStream.
Regards.
Please, correct me. I'm just learning.... and sorry for my english :-)
The code looks good and runs (with minimal modifications) against an Oracle table.
Are you getting an error thrown? Are you certain the update is being committed?
Bookmarks