我正在尝试从数据库中检索Image(Blob)数据但是它给出了我的空指针异常。这有什么问题?这是代码
JButton show = new JButton("New button");
show.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try{
String iid="10";
//iid=id.getText().toString();
String q="select * from image where id='"+iid+"'";
PreparedStatement ps=con.prepareStatement(q);
//ps.setString(1, id.getText());
ps.executeQuery();
ResultSet rs=ps.executeQuery();
while (rs.next()) {
InputStream in = rs.getBinaryStream("image");
bufImg = ImageIO.read(in);
img.setIcon(new ImageIcon (bufImg));
}
rs.close();
ps.close();
}catch(Exception c)
{
c.printStackTrace();
}
}
});