
Hi all, I have a table named tempdb with tempid and zipfile as two column.Currently I am using sybase db.
create table tempdb(tempid int,zipfile image)
i have several zip file stored in this table now I want to retrieve it and put it in an directory in my file system.
PreparedStatement psmt=con.prepareStatement("select * from dbo.temp_blob");
ResultSet rs=psmt.executeQuery();
while(rs.next())
{
System.out.println("PIID IS "+rs.getInt(1));
//ByteArrayOutputStream byt = new ByteArrayOutputStream(1024);
//BufferedInputStream bsstream=new BufferedInputStream(rs.getBinaryStream(2));
Blob b1=rs.getBlob(2);
byte[] barray=b1.getBytes(1,(int)b1.length());
File destinationzip=new File("d://dest.zip");
if(!destinationzip.exists())
{
destinationzip.createNewFile();
}
FileOutputStream fout=new FileOutputStream(destinationzip);
ZipOutputStream zpout=new ZipOutputStream(new BufferedOutputStream(fout));
zpout.write(barray,0,barray.length);
But this not the right approach please tell the proper way to do it.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.