Subject Re: [Firebird-Java] Re: Empty blob query problem
Author William L. Thomson Jr.
On Wed, 2002-07-24 at 01:57, llafranc78 wrote:
> Hi William,
> couldn't you post your code for us to see?

I can, but it worked fine with InterClient.

> I do some queries wich retrieve empty (null) blobs and never had an
> Exception: resultSet.getBytes(i) simply returns null.

That is exactly what I check for, but an exception is being thrown
before I can check the result set.

if (resultSet.getBytes("Picture1")!=null) {
picture1 = new JLabel(new ImageIcon(resultSet.getBytes("Picture1")));
picturesPanel.add(picture1,center);
}
if (resultSet.getBytes("Picture2")!=null) {
picture2 = new JLabel(new ImageIcon(resultSet.getBytes("Picture2")));
picturesPanel.add(picture2,center);
}
if (resultSet.getBytes("Picture3")!=null) {
picture3 = new JLabel(new ImageIcon(resultSet.getBytes("Picture3")));
picturesPanel.add(picture3,center);
}
if (resultSet.getBytes("Picture4")!=null) {
picture4 = new JLabel(new ImageIcon(resultSet.getBytes("Picture4")));
picturesPanel.add(picture4,center);
}
if (resultSet.getBytes("Picture5")!=null) {
picture5 = new JLabel(new ImageIcon(resultSet.getBytes("Picture5")));
picturesPanel.add(picture5,center);
}

But unfortunately my code does not make it this far, because

try {
resultSet.next();
}
catch (SQLException sqle) {
Alert.sql(jDesktopPane,"An error occured while looking up the
inventory item's infomation :\n"+sqle);
}


But my catch statement does not catch it. Instead here is the output
that I get.


Database Exception
Could not execute the following query,
SELECT * FROM INVENTORY WHERE Part_No=1
java.sql.SQLException: You can't read a new blob
java.lang.NullPointerException
at
com.elvisplace.gui.innerframes.ViewInventoryItem$2.actionPerformed(ViewInventoryItem.java:143)

Line 143 is where I call
resultSet.next();

So I would love to know why you think it's the code. Like I said it
worked perfectly with InterClient, but does not with the Firebird JDBC
driver.

Now if all the blobs are full, then it works perfectly. It only takes
one empty blob field to screw it all up.

Now I also have this same problem in another servlet that requests each
blob individually. Luckily only the empty ones fail there, since I am
doing separate queries. There.

Granted I should have made a table to store the blobs, and therefore
would not have any empty blobs, but hind sight is always 50/50. That s
something I may do for the future. But I still want to know why the
exception is being thrown in a manor that does not allow for me to catch
it.


--
Sincerely,
William L. Thomson Jr.
Support Group
Obsidian-Studios Inc.
439 Amber Way
Petaluma, Ca. 94952
Phone 707.766.9509
Fax 707.766.8989
http://www.obsidian-studios.com