I m not able to retrieval blob data from database.....i m new user of db2.....help required......
import java.io.File;
import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
import java.io.InputStream;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class BlobRetrieval {
public static void main(String[] args) {
String databaseDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String dbURL = "jdbc

dbc

EEP";
String userName = "db2admin";
String password = "db2admin";
try {
Class.forName(databaseDriver).newInstance();
Connection connection =
DriverManager.getConnection(dbURL, userName, password);
PreparedStatement preparedStatement =
connection.prepareStatement(
"SELECT img FROM SAGAR.PIC WHERE ID=?");
preparedStatement.setString(1, "0738425826");
ResultSet resultSet = preparedStatement.executeQuery();
while (resultSet.next())
{
// materialization of the Blob
Blob blob = resultSet.getBlob(1);
InputStream inputStream = blob.getBinaryStream();
File fileOutput = new File("C:\\clonedredbookcover.jpg");
FileOutputStream fo = new FileOutputStream(fileOutput);
int c;
while ((c = inputStream.read()) != -1)
fo.write(c);
fo.close();
System.out.println("Blob retrieved");
}
// clean up
preparedStatement.close();
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Error-----unsupporedIOException