Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blob in DB2 with Java

Status
Not open for further replies.

etan

Technical User
Mar 19, 2003
2
CA
Hi, I'm having problem in uploading an image file to the DB2 database. I'm using JDBC2.0. The following is the code:

String sql = ("insert into myblobtable(file_number, uploaded_file) values ("+ fileNumber + ", null)");
String sql1 = ("select * from myblobtable");

try {
poolMgr = PoolManager.getInstance();
System.out.println("DBUtils...poolMgr instantiated");
conn = poolMgr.getConnection();
System.out.println("DBUtils...conn instantiated");
String colName = "Uploaded_File";
stmt = conn.createStatement();
System.out.println("DBUtils...stmt instantiated");
rst = stmt.executeQuery(sql);
rst1 = stmt.executeQuery(sql1);
System.out.println("DBUtils...query executed");
while (rst1.next()){
System.out.println("B4 blob");
Blob blob = rst1.getBlob(colName);
System.out.println("In blob");
}
}
//catch the exception as usual

The message is printed until "B4 blob" only and I received the following error message when I'm trying to call this function.

Root Error-1: COM/ibm/db2/jdbc/app/DB2ResultSet.getBlob
java.lang.AbstractMethodError: COM/ibm/db2/jdbc/app/DB2ResultSet.getBlob at upload.UploadBean.uploadToDb(UploadBean.java:92) at upload.myUploadServlet.processRequest(myUploadServlet.java:46) at upload.myUploadServlet.doPost

Why getBlob() cannot be used? Do you know how to resolve this problem?

Thank you in advance.
 
Instead of:
rst = stmt.executeQuery(sql);
Try:
rst = stmt.executeUpdate(sql);

David B.
 
I could be wrong here, but as this thread is over two years old, Etan was a visitor and has left no 'notify me' details, I don't think that David's reply, as good as it may have been, is going to get to Etan.

Nice try though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top