當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。