You should review ALL of the doc sections related to BLOBs since you would typically access the blob content using streams rather than use the 'getBytes' method.
Once you have your BLOB or CLOB locator in a table, you can access and manipulate the data to which it points. To access and manipulate the data, you first must select their locators from a result set or from a callable statement. After you select the locators, you can retrieve the BLOB or CLOB data. You will usually want to cast the result set to OracleResultSet, so that you can retrieve the data in oracle.sql.* format. After retrieving the BLOB or CLOB data, you can manipulate it however you want. This example is a continuation of the example in the previous section. It uses the SQL SELECT statement to select the BLOB locator from the table my_blob_table into a result set. The result of the data manipulation is to print the length of the BLOB in bytes. // Select the blob - what we are really doing here // is getting the blob locator into a result set BLOB blob; cmd = "SELECT * FROM my_blob_table"; ResultSet rset = stmt.executeQuery (cmd); // Get the blob data - cast to OracleResult set to // retrieve the data in oracle.sql format String index = ((OracleResultSet)rset).getString(1); blob = ((OracleResultSet)rset).getBLOB(2); // get the length of the blob int length = blob.length(); // print the length of the blob System.out.println("blob length" + length); // read the blob into a byte array // then print the blob from the array byte bytes = blob.getBytes(1, length); blob.printBytes(bytes, length);
mfx wrote:Exactly how long does it take?
it runs ok in my dev machine but it is very slow in the server.
I didn't say it wasn't. But your code won't work correctly at all on any version of Oracle prior to 10.2 since for those earlier versions the 'getBytes' method only returns the LOB locator. At a minimum you should include a comment/warning in code whenever you use version-specific features.thank you for the explanation
I suspect the major difference is due to either the Java 7 or the virtual environment. My bet is on the virtual environment; it may be throttlying the bandwidth for large data streams.I concluded that my java machine is in another datacenter from the oracle database. i suspect that firewall is analising sqlnet packages requested by the java machine. i passed the "problem" to the network guys