I am trying to load image in a jTable based on database value.
String query = "SELECT ID, CATEGORY FROM TATTOO_LIB ORDER BY ID DESC";
try {
conn = new data.connection().db();
stmtt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs = stmtt.executeQuery(query);
while (rs.next()) {
//I donot know how to write these lines here...
File f = new File("C:/img/" + rs.getString(1) + ".jpg");
ImageIcon icon = new ImageIcon(f);
model.addRow(new Object[]{icon, rs.getString(1), rs.getString(2)});
}
} catch(SQLException e ) {
JOptionPane.showMessageDialog(null, "Error In Connection!!");
} finally {
try {
stmtt.close();
rs.close();
conn.close();
} catch (SQLException e) {
}
}
How can I load an Image in the first column based on the database value. I tried to follow this and this. But I am lost somewhere. Please help.