JFrameのデータベースから取得した画像を表示する際に問題が発生しています。ここでは、これを解決するために私を助けてください、私が使用すること、 .........JFrameでmysqlから取得した画像を表示する方法
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/studio","root","");
Statement st=con.createStatement();
ResultSet rs = st.executeQuery("select image from photo_instn where cust_id='2'") ;
while(rs.next())
{
byte[] imagedata = rs.getBytes("image") ;
Image img = Toolkit.getDefaultToolkit().createImage(imagedata);
ImageIcon icon =new ImageIcon(img);
JLabel lPhoto = new JLabel(icon) ;
setLayout(null); // BYTES TO IMAGE
System.out.println("Inside");
System.out.println(lPhoto);
this.add(lPhoto) ;
lPhoto.setBounds(200,20,300,400);
}
}
このコードは、フレーム... に表示されていない何problem.butイメージを持っていないです問題....
コードのフォーマットを使用してください。 – Mudassir