Re: image
To: comp.lang.java.gui
Hi vijaya,
I am sending the related code for image.Try with this.
try
{
String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(driverName);
// Create a connection to the database
String url = "jdbc:odbc:elearn" ;
String username = "root";
String password = "root";
//Connection conn = DriverManager.getConnection("jdbc:odbc:elearn");
//PreparedStatement pstmt1 = conn.prepareStatement("SELECT * FROM photo
WHERE username='"+uname+"'");
//ResultSet res = pstmt1.executeQuery();
Connection connection = DriverManager.getConnection(url, username,
password);
Statement s = connection.createStatement();
s.executeQuery("SELECT * FROM photo Where username='"+uname+"'");
ResultSet res = s.getResultSet();
String im ="";
InputStream is = null;
ImageInputStream iis= null;
BufferedImage bImage = null;
if (res != null){
try
{
if (res.next())
{
is = res.getBinaryStream(2);
//iis = ImageIO.createImageInputStream(is);
bImage = ImageIO.read(is);
dPhoto = new ImageIcon(bImage);
JLabel lb=new JLabel(dPhoto);
wpanel.add("Center",lb); //adding to panel
jd.add(wpanel);
}
}
catch (Exception e)
{ e.printStackTrace();
}
}
}
catch (Exception e){
JOptionPane.showMessageDialog(null,"An error occured: " +
e);
}
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24