I'm trying to display images retrieve from MySQL database of blob datatype. Could not figure out what is the problem that causes the image column to display data like this [B@29b8e4f7
instead of image icon.
DefaultTableModel model = new DefaultTableModel(new Object[]{
"image", "item_name", "quantity","price", "category", "color", "size"}, 0){
@Override
public Class<?> getColumnClass(int column) {
switch(column){
case 0: return ImageIcon.class;
default: return String.class;
}
}
};
myTable.setModel(model);
...
ResultSet rs = database.getRS();
int columns = rs.getMetaData().getColumnCount();
while(rs.next()){
Object[] row = new Object[columns];
for(int i = 1; i <= columns; i++){
row[i-1] = rs.getObject(i);
}
DefaultTableModel defmodel = (DefaultTableModel) tableItem.getModel();
defmodel.insertRow(rs.getRow()-1, row);
}