wood burning stoves
The moose likes JDBC and Relational Databases and the fly likes Search for Text in a BLOB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Search for Text in a BLOB" Watch "Search for Text in a BLOB" New topic

Search for Text in a BLOB

Rohit Kedia
Ranch Hand

Joined: Apr 24, 2010
Posts: 79
I am using a this Query to search a Text from a BLOB field. I am getting results for .doc ,.xls, .ppt, .txt files. But I am unable to find any help for searching in a .docx or any 2007 Office file formats and also for PDF files in a BLOB fields.

Please help me in this Issue.

Lester Burnham

Joined: Oct 14, 2008
Posts: 1337
The DB has no notion of searching inside of BLOBs in general, or of structured file formats specifically. You could extract the text from those documents and store it in an additional text field, which could then be searched by SQL. The Apache POI library can do this for Office file formats, and Apache PDFBox for PDFs.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

A BLOB doesn't store text. It stores binary data.

As Lester noted, the database has no way of knowing what is in your BLOB. It could be a Word document or it could be a bunch of random bytes.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

Some databases (Oracle for example) allow BLOB-like data types like CLOB/XML that do allow searching.

[OCA 8 Book] [Blog]
I agree. Here's the link: http://aspose.com/file-tools
subject: Search for Text in a BLOB
It's not a secret anymore!