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

The following are Jave code examples for showing how to use getStatement() 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.
+ Save this method
Example 1
Project: aceql-http   File: PostgreSqlUtil.java   View Source Code Vote up 7 votes
/**
    * Extract the Large Object Input Stream from PostgreSQL
    * 
    * @param resultSet
    *            the Result Set to extract the blob from
    * @param columnIndex
    *            the index of column
    * @return the Large Object Input Stream from PostgreSQL
    * @throws SQLException
    */
   public static InputStream getPostgreSqlnputStream(ResultSet resultSet,
    int columnIndex) throws SQLException {
InputStream in;
Statement statement = resultSet.getStatement();
Connection conn = statement.getConnection();

// Get the Large Object Manager to perform operations with
LargeObjectManager lobj = ((org.postgresql.PGConnection) conn)
	.getLargeObjectAPI();
long oid = resultSet.getLong(columnIndex);

if (oid < 1) {
    return null;
}

LargeObject obj = lobj.open(oid, LargeObjectManager.READ);

in = obj.getInputStream();
return in;
   }
 
Example 2
Project: lams   File: JdbcCoordinatorImpl.java   View Source Code Vote up 7 votes
@Override
public void register(ResultSet resultSet, Statement statement) {
	if ( statement == null ) {
		try {
			statement = resultSet.getStatement();
		}
		catch ( SQLException e ) {
			throw exceptionHelper.convert( e, "unable to access statement from resultset" );
		}
	}
	if ( statement != null ) {
		LOG.tracev( "Registering result set [{0}]", resultSet );
		Set<ResultSet> resultSets = xref.get( statement );
		if ( resultSets == null ) {
			LOG.unregisteredStatement();
		}
		if ( resultSets == null || resultSets == EMPTY_RESULTSET ) {
			resultSets = new HashSet<ResultSet>();
			xref.put( statement, resultSets );
		}
		resultSets.add( resultSet );
	}
	else {
		unassociatedResultSets.add( resultSet );
	}
}
 
Example 3
Project: azeroth   File: JDBCUtils.java   View Source Code Vote up 7 votes
/**
 * Close connection
 *
 * @param rs
 */
public static void close(ResultSet rs) {
    Statement st = null;
    Connection con = null;
    try {
        try {
            if (rs != null) {
                st = rs.getStatement();
                rs.close();
            }
        } finally {
            try {
                if (st != null) {
                    con = st.getConnection();
                    st.close();
                }
            } finally {
                if (con != null) {
                    con.close();
                }
            }
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
 
Example 4
Project: jdbacl   File: DBUtil.java   View Source Code Vote up 6 votes
public static Statement getStatement(ResultSet resultSet) {
	try {
		return resultSet.getStatement();
	} catch (SQLException e) {
		throw new RuntimeException("Error getting statement from result set", e);
	}
}
 
Example 5
Project: aceql-http   File: ResultSetWriter.java   View Source Code Vote up 6 votes
/**
    * Returns true if engine is terradata
    * 
    * @param resultSet
    *            the result set in use
    * @returns true if engine is terradata
    * @throws SQLException
    */
   private String getDatabaseProductName(ResultSet resultSet)
    throws SQLException {

Statement statement = resultSet.getStatement();

// happens on Metadata requests, we don' care about the result:
if (statement == null) {
    return "unknown";
} else {
    Connection connection = statement.getConnection();
    return new SqlUtil(connection).getDatabaseProductName();
}
   }
 
Example 6
Project: lams   File: JdbcCoordinatorImpl.java   View Source Code Vote up 6 votes
@Override
public void release(ResultSet resultSet, Statement statement) {
	LOG.tracev( "Releasing result set [{0}]", resultSet );
	if ( statement == null ) {
		try {
			statement = resultSet.getStatement();
		}
		catch ( SQLException e ) {
			throw exceptionHelper.convert( e, "unable to access statement from resultset" );
		}
	}
	if ( statement != null ) {
		final Set<ResultSet> resultSets = xref.get( statement );
		if ( resultSets == null ) {
			LOG.unregisteredStatement();
		}
		else {
			resultSets.remove( resultSet );
			if ( resultSets.isEmpty() ) {
				xref.remove( statement );
			}
		}
	}
	else {
		final boolean removed = unassociatedResultSets.remove( resultSet );
		if ( !removed ) {
			LOG.unregisteredResultSetWithoutStatement();
		}
	}
	close( resultSet );
}
 
Example 7
Project: calcite-avatica   File: JdbcMeta.java   View Source Code Vote up 6 votes
/**
  * Registers a StatementInfo for the given ResultSet, returning the id under
  * which it is registered. This should be used for metadata ResultSets, which
  * have an implicit statement created.
  */
private int registerMetaStatement(ResultSet rs) throws SQLException {
  final int id = statementIdGenerator.getAndIncrement();
  StatementInfo statementInfo = new StatementInfo(rs.getStatement());
  statementInfo.setResultSet(rs);
  statementCache.put(id, statementInfo);
  return id;
}