• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

how to handle data gotten from CLOBs?

 
Greenhorn
Posts: 6
  • 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?
 
Marshal
Posts: 25811
69
Eclipse IDE Firefox Browser MySQL Database
  • 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
  • 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
Marshal
Posts: 25811
69
Eclipse IDE Firefox Browser MySQL Database
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much good sir.
 
Did you miss me? Did you miss this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic