Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ResultSet.getBytes Question

 
Mike London
Ranch Hand
Posts: 1227
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my code, if I have two statements like the ones below (as an experiment, naturally), the second variable, imageBytes2 has all zeros. The first variable, imageBytes, has the expected data.

However, based on this experiment it looks like the first getBytes is actually removing the data from the ResultSet.


Does this make sense?

In other places, for say an integer PK, I can repeatedly refer to the ResultSet value (of course, creating a simple variable the first time, is the best idea).

Now that I debugged it to find this behavior, it's simple to reproduce. (The solution, of course, is just to use a variable equal to "imageBytes" in the first line, but this is confusing since I can repeatedly refer to a ResultSet field with other data types....???).

Thanks,

-mike
 
Paul Clapham
Sheriff
Posts: 21581
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess? It's a "feature" of the JDBC driver. There are some drivers which don't let you read the same column of any type twice, or require you to read them in order.

But it might also be a bug -- do the API docs mention that the method can do that?
 
Mike London
Ranch Hand
Posts: 1227
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:My guess? It's a "feature" of the JDBC driver. There are some drivers which don't let you read the same column of any type twice, or require you to read them in order.

But it might also be a bug -- do the API docs mention that the method can do that?


This was the current JDBC driver for FileMaker Pro. There is scant documentation other than a few sample calls in a small PDF Reference.

I'm guessing it must be (since I can re-read some columns)... a bug. Plus, I can even re-read the getBytes() column for small image sizes. I didn't do extensive testing, but it seemed that trying to do a second getBytes() on an image column (or other blob type data, a "Container" in FMP) over, say 200KB, would zero out the bytes read.

I'll just chalk it up to a few hours invested in the debugger!

Thanks very much for your reply. :)

-mike
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic