• Post Reply Bookmark Topic Watch Topic
  • New Topic

BLOB Problem in DB2

Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing the following problem while inserting a record with BLOB. See the following Java Program.
public boolean METHOD_NAME()
boolean sucessFlag = false;
File fileObject = new File("FILE_NAME.XLS");
FileInputStream finObject = new FileInputStream(fileObject);
Connection con = DbUtil.getDBConnention();
StringBuffer sb = new StringBuffer();
PreparedStement pstmt = con.prepareStement(sb.toString());
pstmt.setBinaryStream(1, finObject, fileObject.length());
boolean sucessFlag = pstmt.execute();
The above code is executing fine without having Exception. But, I am getting successFlag as false after executing the SQL. Can anyone help me.
I am using DB2 Universal JDBC 2 Driver.
Jeanne Boyarsky
author & internet detective
Posts: 36032
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, how did this compile? You have the variable "sucessFlag" defined twice.
However, the code is acting as expected. The javadoc for execute() says that it returns true if the query returns a resultset and false if the query returns an update count. You would have to call getUpdateCount() to get the real result.
It is easier to call executeUpdate() instead of execute(). It is also clearer as to your intent. executeUpdate() returns the number of rows updated.
Bear Bibeault
Author and ninkuma
Posts: 65680
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch Senthamizh!
You'll find this forum a great place to seek help on JDBC, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
Forum Bartender
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!