List of utility methods to do SQL ResultSet Blob Read
byte[] | getBlob(ResultSet results, int parameterIndex) get Blob Blob value = results.getBlob(parameterIndex); if (results.wasNull()) { return null; byte[] data = value.getBytes(0, (int) value.length()); value.free(); return data; |
byte[] | getBlobAsByteArray(final ResultSet rs, final int ind) get Blob As Byte Array final Blob blob = rs.getBlob(ind); if (blob == null) { return null; final long len = blob.length(); if (len <= 0L) { return null; if (blob.length() > Integer.MAX_VALUE) { throw new SQLException("BLOB exceeds Integer.MAX_VALUE in length; cannot be retrieved as byte array"); return blob.getBytes(1L, (int) len); |
byte[] | getBlobAsBytes(ResultSet rs, int col) get Blob As Bytes Blob dataAsBlob = rs.getBlob(col); return dataAsBlob.getBytes(1, (int) dataAsBlob.length()); |
byte[] | getBlobBytes(ResultSet rs, int iColumn) Gets the binary content from a column and returns it as a byte array return readStreamToByteArray(rs.getBinaryStream(iColumn));
|
String | getBlobValue(ResultSet result, String strField) get Blob Value String strValueReturn = ""; Blob blob = result.getBlob(strField); if (result.wasNull()) { strValueReturn = ""; } else { int length = (int) blob.length(); if (length > 0) strValueReturn = new String(blob.getBytes(1, length)); ... |
byte[] | readBlob(ResultSet rs, int index) Read the blob associated with the column with the specified index from the specified result set. ByteArrayOutputStream bos = null; BufferedInputStream in = null; try { bos = new ByteArrayOutputStream(); in = new BufferedInputStream(rs.getBinaryStream(index)); int noBytes; byte[] tmpBuffer = new byte[1024]; while ((noBytes = in.read(tmpBuffer)) != -1) { ... |
String | readBlobUTF16BinaryStream(ResultSet rs, String fieldName) read Blob UTF Binary Stream return null;
|
String | readBlobUTF16BinaryStream(ResultSet rs, String fieldName) read Blob UTF Binary Stream Blob clob = rs.getBlob(fieldName); InputStream is = clob.getBinaryStream(); StringBuffer sb = new StringBuffer(); int readedBytes = 0; int bufferSize = 4096; do { byte[] bytes = new byte[bufferSize]; readedBytes = is.read(bytes); ... |
byte[] | readFromBlob(ResultSet rs, String column) read From Blob byte[] ret = null; Blob blob = rs.getBlob(column); if (blob != null) { long length = blob.length(); if (length == 0) ret = new byte[0]; } else { ... |