我将访问者的图像和其他详细信息存储到表 tbl_visitor 中。代码如下,
String string_op="F:\\POSTERS\\Roses\\TROPIC4.png";
File imageFile = new File(string_op);
FileInputStream fis = new FileInputStream(imageFile);
String queryVis="insert into tbl_visitor(visitor_name,contact_no," +
"job_profile,org_name,photo_id_proof,type_of_visitor,date," +
"extra_people,image) values('"+
name_of_visitor.getText()+"','"+
contact_num.getText()+"','"+
job_profile.getText()+"','"+
org.getText()+"','"+
photo_id_num.getText()+"','"+
type_of_visitor.getSelectedItem().toString()+"','"+
date_and_time.getText()+"','"+
tf1.getText()+"','"+
"fis,(int)imageFile.length()"+"')";
现在我想在 JFrame 上显示图像并使用 JLabel 显示图像,但我无法将图像分配给 JLabel。我尝试了以下代码来显示图像,但它给了我错误。
Blob image_vis = rs1.getBlob(10);
image_cap.setIcon(image_vis);
请帮我。