Retrieving Blobs from Oracle using DBToolsJ

Article ID: 1033
Last updated: 02 Feb, 2008
Article ID: 1033
Last updated: 02 Feb, 2008
Revision: 1
Views: 2863
Posted: 14 Jul, 1998
by Dean J.
Updated: 02 Feb, 2008
by Dean J.
Problem


I cannot access blobs from Oracle using DBToolsJ.


Cause


There is no built-in class to handle blobs in DBToolsJ.


Action


Here is a sample program written with DBToolsJ that retrieves blobs from the database.
import com.roguewave.dbtools.v2_1.*;
import com.roguewave.dbtools.v2_1.jdbc.*;
import com.roguewave.dbtools.v2_1.Connection;
import java.util.*;
import java.sql.*;
import java.math.*;
import java.io.InputStream;

public class In {
public static void runTest(ConnectionPool pool, Server server, Connection cn)
throws DatabaseException, LoginFailureException
{
cn.executeSql("drop table test");
cn.executeSql("create table test (f1 int, f2 long)");
cn.executeSql("insert into test values (1, 'abcd')");
DBTable test = new DBTable("test");

Reader rdr = test.getReader(cn);
while (rdr.nextRow()) {
int x = rdr.getInt();
InputStream y = rdr.getBinaryStream();

System.out.println("x: " + x);
byte[] b = new byte[255];
int n = -255;
try { n = y.read(b);} catch (java.io.IOException e) { e.printStackTrace(); }
System.out.println("read " + n + " bytes");
String res = new String();
for (int i = 0; i

This article was:   Helpful | Not helpful
Report an issue
Article ID: 1033
Last updated: 02 Feb, 2008
Revision: 1
Views: 2863
Posted: 14 Jul, 1998 by Dean J.
Updated: 02 Feb, 2008 by Dean J.

Others in this category