Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to handle data gotten from CLOBs?

 
Philip Fry
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I need some guidance with handling clob data. I have a derby table:

Hashes and salts are generated like this:

Then records are stored like this:

This bit works fine. At least I am convinced so.
Once I store the digests in a DB I use this method to compare them:

Hash and salt arguments being passed to the compareHashes() are the ones retrieved from a database with:

and also:

Clearly I am doing something wrong with getting data from Clobs. And this:

is the only way I coud come up with to convert the clob back to array, which isn't working like i would like it to. I thought byte[] arrays passed were binary and since clobs are? also binary it would work with out additional conversions.
Do any of you have any ideas/suggestions/libraries which would be able to convert the clobs to what I want?
 
Paul Clapham
Sheriff
Pie
Posts: 20177
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Philip Fry wrote:since clobs are? also binary


CLOB: Character Large Object

BLOB: Binary Large Object
 
Philip Fry
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was under the impression that blobs were for files like media files or pictures? Also I am not able to insert to Blob type fields things like: 81-88108101-39-95348102-413-2318-44-95-4029-92-11-53115-124-89-89080-102126888411531
because an exception is being thrown:



And it works with clobs type fields.
 
Paul Clapham
Sheriff
Pie
Posts: 20177
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Philip Fry wrote:I was under the impression that blobs were for files like media files or pictures? Also I am not able to insert to Blob type fields things like: 81-88108101-39-95348102-413-2318-44-95-4029-92-11-53115-124-89-89080-102126888411531
because an exception is being thrown:


Blobs are -- just as their name says -- Binary Large Objects. It's true that the files you mention are binary and can be large, but it doesn't follow from that statement that you can't use Blobs for anything else.

And no, you can't put character data into them. You have to put bytes into them. Naturally you can't do that if you're constructing your SQL statements in a String (I can't believe you're doing all of this login security and then using a technology which is susceptible to SQL injection attacks). You can put bytes into them if you use a PreparedStatement and then use its setBlob() or setBinaryStream() method.
 
Philip Fry
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much good sir.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic