This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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
Author

Search for Text in a BLOB

Rohit Kedia
Ranch Hand

Joined: Apr 24, 2010
Posts: 79
Hi,
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
Rancher

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
Marshal

Joined: May 26, 2003
Posts: 32481
    
214

Rohit,
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
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3740
    
  10

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!