Problems about SQL Server Access Image Data

zhaozj2021-02-16  178

Master please help: Now the Catinfo table in SQL Server 2000 Database Busmgsys is named CATPHOTO, the type image type is used to store the image, and set a busmgsys data source in the ODBC data source, the username SA, password SA, now To read this image data from the database, the code is: public class readimage {public static void main (string [] args) {readimageFromDatabase ();

} Public void readimageFromDatabase () {Import javax.swing. *; Import java.io. *; try {// load JDBC driver class.Forname ("sun.jdbc.odbc.jdbcodbcdriver"); // with JDBC-ODBC bridge to connect connection con = DriverManager.getConnection ( "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 a stream of input flows 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.Read (ImageDataS);} catch (exception e) {E.PrintStackTrace ();}}}

One runs to imagestream = ((InputStream) Result.getBinaryStream ("CatPhoto")); this line has a lower case error:

java.io.IOException at sun.jdbc.odbc.JdbcOdbcInputStream.available (JdbcOdbcInputStream.java:300) at ReadImage.readImageFromDataBase (ReadImage.java:494) at ReadImage $ 2.run (ReadImage.java:156) at java.awt. event.InvocationEvent.dispatch (InvocationEvent.java:178) at java.awt.EventQueue.dispatchEvent (EventQueue.java:448) at java.awt.EventDispatchThread.pumpOneEventForHierarchy (EventDispatchThread.java:197) at java.awt.EventDispatchThread.pumpEventsForHierarchy (EventDispatchThread.java:150) at java.awt.EventDispatchThread.pumpEvents (EventDispatchThread.java:144) at java.awt.EventDispatchThread.pumpEvents (EventDispatchThread.java:136) at java.awt.EventDispatchThread.run (EventDispatchThread.java: 99) Please give pointers, I will be grateful !!!!!!!!!!

转载请注明原文地址:https://www.9cbs.com/read-7965.html

New Post(0)