Java Code Examples for java.sql.Statement.getConnection()

The following are Jave code examples for showing how to use getConnection() of the java.sql.Statement 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: aceql-http   File: PostgreSqlUtil.java   Source Code and License Vote up 8 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: azeroth   File: JDBCUtils.java   Source Code and License 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 3
Project: aceql-http   File: ResultSetWriter.java   Source Code and License 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();
}
   }