ByteArrayOutputStream out = null;
BufferedInputStream in = null;
ResultSet rs = null;
Statement stmt = null;
byte[] result = {};
Blob blob;
int bytesRead;
try {
logger.debug9("calling " + SOSClassUtil.getMethodName());
if (connection == null)
throw new Exception(
SOSClassUtil.getMethodName()
+ ": sorry, there is no successful connection established."
+ " may be the connect method was not called");
query = normalizeStatement(query, replacement);
if (profiler != null) try {
profiler.start(query);
} catch (Exception e) {
}
stmt = connection.createStatement();
logger.debug6(".. " + query);
rs = stmt.executeQuery(query);
if (rs.next()) {
blob = rs.getBlob(1);
if (blob == null) {
logger.debug9(".. ResultSet returns NULL value.");
return result;
}
byte[] data = new byte[(int) blob.length()];
out = new ByteArrayOutputStream((int) blob.length());
in = new BufferedInputStream(blob.getBinaryStream());
if (in == null) {
logger
.debug9(".. ResultSet InputStream returns NULL value.");
return result;
}