本文整理匯總了Java中java.sql.ResultSet.getAsciiStream方法的典型用法代碼示例。如果您正苦於以下問題:Java ResultSet.getAsciiStream方法的具體用法?Java ResultSet.getAsciiStream怎麽用?Java ResultSet.getAsciiStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.sql.ResultSet
的用法示例。
在下文中一共展示了ResultSet.getAsciiStream方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getResultAsEscapedString
import java.sql.ResultSet; //導入方法依賴的package包/類
@Override
protected String getResultAsEscapedString( ResultSet resultSet, int index,
String columnTypeName ) throws SQLException, IOException {
String value;
Object valueAsObject = resultSet.getObject(index);
if (valueAsObject == null) {
return null;
}
if (valueAsObject != null && valueAsObject.getClass().isArray()) {
if (! (valueAsObject instanceof byte[])) {
// FIXME other array types might be needed to be tracked in a different way
log.warn("Array type that needs attention");
}
// we have an array of primitive data type
InputStream is = null;
try {
is = resultSet.getAsciiStream(index);
value = IoUtils.streamToString(is);
} finally {
IoUtils.closeStream(is);
}
} else if (valueAsObject instanceof Blob) {
// we have a blob
log.debug("Blob detected. Will try to dump as hex");
Blob blobValue = (Blob) valueAsObject;
InputStream blobInputStream = blobValue.getBinaryStream();
StringBuilder hexString = new StringBuilder();
//read the binary data from the stream and convert it to hex according to the sample from
// http://www.herongyang.com/jdbc/Oracle-BLOB-SQL-INSERT.html - see 3 variants for Oracle, MsSQL and MySQL
hexString = addBinDataAsHexAndCloseStream(hexString, blobInputStream);
value = hexString.toString();
} else {
// treat as a string
value = resultSet.getString(index);
logDebugInfoForDBValue(value, index, resultSet);
}
return value;
}
示例2: getClobAsAsciiStream
import java.sql.ResultSet; //導入方法依賴的package包/類
@Override
public InputStream getClobAsAsciiStream(ResultSet rs, int columnIndex) throws SQLException {
logger.debug("Returning CLOB as ASCII stream");
if (this.wrapAsLob) {
Clob clob = rs.getClob(columnIndex);
return clob.getAsciiStream();
}
else {
return rs.getAsciiStream(columnIndex);
}
}
示例3: testGetAsciiStream
import java.sql.ResultSet; //導入方法依賴的package包/類
public void testGetAsciiStream(ResultSet resultSet) throws SQLException {
try {
resultSet.getAsciiStream(ordinal);
fail("Was expecting to throw SQLDataException");
} catch (Exception e) {
assertThat(e, isA((Class) SQLDataException.class)); // success
}
}