Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I insert bytes into a sql query?

843859Jun 16 2010 — edited Nov 20 2014
Hello,

I am having much difficulty trying to figure this out. I've looked at the derby and jdbc documentation but I only got hints on how to accomplish this.

Here is my problem:

I have a table as follows:
create table users (uid char(5) for bit data not null, primary key (uid))
Now when I want to fill in values for this I can easily do the following:
result.moveToInsertRow();
result.updateBytes(1, myBytes);
result.insertRow();
where myBytes is a byte array with length 5.

But when I want to search for a specific row, I am clueless as to how I can go about inserting the byte array into the WHERE clause:
select * from users where uid=???
From this page: http://db.apache.org/derby/docs/10.6/ref/rrefsqlj57924.html There is a demonstration of inserting hexadecimal values into the row but does this mean I have to convert my byte array into a hexadecimal string for the query?

Another question: is there no jdbc function similar to ResultSet.updateBytes(int,byte[]) that I could use to insert my byte data into the WHERE clause of my query?

Thanks!
Daniel K
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 14 2010
Added on Jun 16 2010
2 comments
1,538 views