Public void readimageFromDatabase () {Import javax.swing. *; Import java.io. *; try {// Define a JLabel used to display images JLabel LBphoto = new jlable (); // Load JDBC driver class.forname (" Sun.jdbc.odbc.jdbcodbcdriver "); // Connect connection con = DriverManager.getConnection with JDBC-ODBC Bridge (" JDBC: ODBC: Busmgsys "," SA "," SA "); statement statement = con.createstatement ); ResultSet Result = statement.executeQuery ("Select Catphoto from catinfo);
if (Result.next) {// Defines a Byte [] array to temporarily read photos read from the database Byte [] imageDataS = null; // Define an input flow to accept streams read from the database InputStream Imagestream ;
// Log from the number of images in the database Imagestream = ((InputStream) Result.GetBinaryStream ("CatPhoto")); // is in this line
// Put the image data into the imageDataS array to imageDataS.read (ImageDataS); // put the image to lbphoto (new imageicon (imagedata));} catch (exception e) {e. PRINTSTACKTRACE ();
}
Help