1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| package image;
import java.sql.*;
import java.io.*;
import java.util.*;
import oracle.jdbc.*;
import oracle.sql.*;
public class images
{
/*-------------------------
* Get the Blob image
*------------------------*/
public static byte[] getPhoto (OracleConnection conn, int iNumPhoto)
throws Exception, SQLException
{
String req = "" ;
Blob img ;
byte[] imgData = null ;
Statement stmt = conn.createStatement ();
// Query
req = "Select image From IMAGES Where ImageID = " + iNumPhoto ;
ResultSet rset = stmt.executeQuery ( req );
while (rset.next ())
{
img = rset.getBlob(1);
imgData = img.getBytes(1,(int)img.length());
}
rset.close();
stmt.close();
return imgData ;
}
} |