当前位置: 首页>>代码示例>>Java>>正文


Java ResultSet.getAsciiStream方法代码示例

本文整理汇总了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;
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:42,代码来源:MssqlDbProvider.java

示例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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:DefaultLobHandler.java

示例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
  }
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:9,代码来源:AvaticaResultSetConversionsTest.java


注:本文中的java.sql.ResultSet.getAsciiStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。