1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| public void afficher(){
// byte[] fileBytes;
byte[] imgData = null ;
DefaultTableModel model = new DefaultTableModel();
model.addColumn("IMAGE_ID");
model.addColumn("IMAGE_NAME");
model.addColumn("IMAGE_DATA");
//Blob img ;
// byte[] imgData = null ;
String requetteaffiche="SELECT * FROM saved_image ";
try {
st=maconnexion.obtenir().createStatement();
ResultSet resultat=st.executeQuery(requetteaffiche);
while (resultat.next()) {
String id = rs.getString(0);
String name=rs.getString(1);
Blob blob = rs.getBlob(2);
ImageIcon icon = null;
InputStream is = blob.getBinaryStream();
BufferedImage img = ImageIO.read(is);
icon = new ImageIcon(img);
model.addRow(new Object[]{resultat.getString("IMAGE_ID"),icon});
}
} catch (Exception e) {
System.out.println(e);
}
jtable.setModel(model);
} |
Partager