本文整理汇总了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
}
}