Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JLabel lblPicture = new JLabel("New label");
- lblPicture.setBounds(34, 82, 245, 184);
- contentPane.add(lblPicture);
- try {
- Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/javadb", "root", "");
- byte b[];
- Blob blob;
- PreparedStatement ps=conn.prepareStatement("select * from images");
- ResultSet rs=ps.executeQuery();
- while(rs.next()){
- blob=rs.getBlob("img");
- b=blob.getBytes(1,(int)blob.length());
- BufferedImage img = null;
- img = ImageIO.read(new ByteArrayInputStream(b));
- lblPicture.setIcon(new ImageIcon(img));
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement