Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6249043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:10:02+00:00 2026-05-24T13:10:02+00:00

I am using Derby database. I wrote this query: InputStream is = new java.io.ByteArrayInputStream(BYTES);

  • 0

I am using Derby database. I wrote this query:

InputStream is = new java.io.ByteArrayInputStream(BYTES);
PreparedStatement st11 = conn.prepareStatement("select f from a1 where dBlob =?)");
st11.setBlob(1,is,BYTES.length);

dBlob is a BLOB datatype.
BYTES is also a BLOB datatype.

But I get the following exception when I execute this query:

Caused by: ERROR 42818: Comparisons between ‘BLOB’ and ‘BLOB’ are not supported.
Types must be comparable. String types must also have matching collation. If co
llation does not match, a possible solution is to cast operands to force them to
the default collation (e.g. SELECT tablename FROM sys.systables WHERE CAST(tabl
ename AS VARCHAR(128)) = ‘T1’)

How can write the query to circumvent this problem ?

I have also tried using Convert, but it doesn’t work with that too:

PreparedStatement st11 = conn.prepareStatement("select f from a1 where dBlob    
=CONVERT(?,BINARY)");
st11.setBlob(1,is,BYTES.length);

Moreover, is it possible to get the datatype of the argument being passed in ? by reflection or by some other means.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:10:03+00:00Added an answer on May 24, 2026 at 1:10 pm

    The inability to search directly on a BLOB column is a very fundamental limitation, and I don’t think you’ll be able to circumvent it.

    If your application requires that you routinely search the database by exact match on BLOB data, what I generally do in my applications is to add an additional column to the database, of type VARCHAR(128), and store a SHA-1 hash of the BLOB value in the hash column.

    Then, to search your database, compute the hash of the blob you want to search for, and search the hash column for an exact match.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been developing a Java application using J2EE and a Derby database. My
I need to enumerate the tables in a Derby (aka Java DB) database using
I have (java) code that creates and populates tables in a derby database, using
I'm using derby as an embedded database. Furthermore, I'm using it's in-memory database option
Using the embedded driver I can connect to my derby database using the JDBC
I am using apache derby for my database. I am able to perform inserts
I am using Spring + EclipseLink 2 to manage entity on a Derby database.
I have a Java app that has an embedded Derby database (no hibernate though).
I'm using the Apache Derby embedded database for unit testing in a Maven project.
Using Apache Derby with Java (J2ME, but I don't think that makes a difference)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.