Java Code Examples for java.sql.ResultSet.getAsciiStream()

The following are Jave code examples for showing how to use getAsciiStream() of the java.sql.ResultSet class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: ats-framework   File:   Source Code and License Vote up 5 votes
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 {
    } 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
        // - 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;
Example 2
Project: lams   File:   Source Code and License Vote up 5 votes
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);
Example 3
Project: calcite-avatica   File:   Source Code and License Vote up 5 votes
public void testGetAsciiStream(ResultSet resultSet) throws SQLException {
  try {
    fail("Was expecting to throw SQLDataException");
  } catch (Exception e) {
    assertThat(e, isA((Class) SQLDataException.class)); // success