How to Stored images into a table?
Public class img
{
public static void main(String args[])
{
class.forName();
Connection con=Drivermanager.getConnection();
PreparedStatement pstmt=con.prepareStatement(“insert into image value(?)”);
FileInutStream fis=new FileInputStream(“a.gif”);
Pstmt.setBinaryStream (1,fis,fis.available);
int i=pstmt.executeUpdate();
}
}
How to retrieve image from a table?
public class img
{
public static void main(String args[])
{
class.forName();
Connection con=Drivermanager.getConnection();
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(“select * from img”);
rs.next();
InputStream is=rs.getBinaryStream(1);
FileOutPutStream fos=new FileOutPutStream(“g2.gif”);
int ch;
while(ch=is.read(1)!=!-1)
{
fos.write(ch);
}
}
What are the methods() to retrieve very large values from database?
getAsciiStream () àread values which are character in nature.
getBinaryStream()àused to read images.
No comments:
Post a Comment