I already did the image browsing and this is my code for the upload button,
// im taking the path of the image from where i retrieved from browsing to a variable called 'pic'...and also im getting the Id of a student to enter in with the pic into the database
String pic = path.getText();
int sid= Integer.parseInt(SID.getText());
// created a data access object called upload in the DAO in another frame to send the image to the database through this form where i have written the method for it to convert the image into a bit stream
and im getting errors in the runtime saying "java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0)." So is my method incorrect and is there more errors apart from this and what can i do ???
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 ???
You cannot insert the image directly in table.
try the following steps,
1.insert the person_id first, PreparedStatement ps = dbConn.prepareStatement("insert into image(person_id) values(?)");
2.Then update the person_id with image using update query update image set image = ? where person_id = ?
hope you understand.
do remeber you cannot insert the image using insert comment anyhow it does not show any error but you cannot retrive it again.