-
August 17th, 2011, 04:43 AM
#1
problem while image insertion
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?
-
August 17th, 2011, 06:43 AM
#2
Re: problem while image insertion
Hi,
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 :-)
-
August 17th, 2011, 07:47 AM
#3
Re: problem while image insertion
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|