Aruna Jayabalu wrote:What is the datatype of the image column in your database?
Check for the column size also..
Thanks,
Aruna.J
Aruna Jayabalu wrote:stmt.setInt(1, sid);
stmt.setString(1,fin);
You are trying to set both sid and fin to the 1st parameter person_id.
This is the reason for the error. Change it to 2 and try once.
Thanks,
Aruna.J
Aruna Jayabalu wrote:Your prepared statement usage is wrong..
You are trying to set 3 values for 2 parameters which is again wrong.
Just try like this
File file = new File("myimage.gif");
FileInputStream fis = new FileInputStream(file);
PreparedStatement ps =
conn.prepareStatement("insert into images values (?,?)");
ps.setString(1,file.getName());
ps.setBinaryStream(2,fis,(int)file.length());
ps.executeUpdate();
ps.close();
fis.close();
Change accordingly.
Thanks,
Aruna.J
Jesper de Jong wrote:When you use PreparedStatement, there must be question marks "?" in the SQL string in the place where you want to have the parameter values inserted.
You don't have question marks there, you are just concatenating values into the string:
Heshan Perera wrote:
Jesper de Jong wrote:When you use PreparedStatement, there must be question marks "?" in the SQL string in the place where you want to have the parameter values inserted.
You don't have question marks there, you are just concatenating values into the string:
Thankz alot it works
Heshan Perera wrote:
Heshan Perera wrote:
Jesper de Jong wrote:When you use PreparedStatement, there must be question marks "?" in the SQL string in the place where you want to have the parameter values inserted.
You don't have question marks there, you are just concatenating values into the string:
Thankz alot it works
Ohhh and btw i, also adding more details of the person to the database..thereofore when i add the details and photos seperately the primary key gets duplicated....therefore in the above query statement i want to have only 1 parameter(the image) to be selected by the WHERE clause...as in like this..,
PreparedStatement ps = dbConn.prepareStatement("insert into image(image) values(?) where person_id="+sid+");
now is this correct then?? or is this line should be modified ???
Don't get me started about those stupid light bulbs. |