On Dec 30, 7:05 pm, shweta.kapar....DeleteThis@googlemail.com wrote:
> On Dec 27, 3:37 pm, Steve Howard wrote:
>
> > On Dec 26, 4:11 pm, shweta.kapar....DeleteThis@googlemail.com wrote:
>
> > > Hi All
> > > How to read BLOB column using simple method.
> > > I can do using TOAD ( export option).
> > > Regards
>
> > Hi,
>
> > What application platform (java, .Net, etc.) environment are you
> > using?
>
> > Regards,
>
> > Steve
>
> Hi Steve,
> Sorry for the late response.
> We are using Java. And we keep JMS database for message store. It has
> tables with BLOB cols. those i wanted to read.
> Regards
Try this...
SQL> select dbms_lob.substr(b,2000,1) from blobtest;
DBMS_LOB.SUBSTR(B,2000,1)
--------------------------------------------------------------------------------
7F454C460101010000000000000000000200030001000000208C040834000000582E000000000000
34002000080028002300200006000000340000003480040834800408000100000001000005000000
04000000030000003401000034810408348104081300000013000000040000000100000001000000
000000000080040
SQL> desc blobtest;
Name Null? Type
----------------------------------------- --------
----------------------------
C NUMBER
B BLOB
SQL> exit
linux2:oracle:tst10g1:/home/oracle>cat readBlob.java
import java.sql.*;
import oracle.jdbc.driver.*;
public class readBlob {
public static void main (String args[]) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:rep/rep@192.168.1.54:1521:tst10g1");
PreparedStatement psGetBlob = conn.prepareStatement ("select b "
+
"from
blobtest " +
"where c
= ?");
psGetBlob.setInt(1, Integer.parseInt(args[0]));
ResultSet rst = psGetBlob.executeQuery();
if (rst.next()) {
oracle.sql.BLOB blob = ((OracleResultSet)rst).getBLOB(1);
System.out.println(blob);
}
rst.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
linux2:oracle:tst10g1:/home/oracle>java readBlob 1
oracle.sql.BLOB@83ad50
>> Stay informed about: How to read BLOB data from Oracle table