There are four pairs of methods in the
Example code:
java.sql.ResultSet class that deal with BLOBs/CLOBs: -
Reader getCharacterStream(int columnIndex)/
Reader getCharacterStream(String columnName) -
InputStream getBinaryStream(int columnIndex)/
InputStream getBinaryStream(String columnName) -
Blob getBlob(int i)/Blob getBlob(String colName) -
Clob getClob(int i)/Clob getClob(String colName)
Example code:
PreparedStatement pstmt = conn.prepareStatement("SELECT image FROM photos where id = ?"); pstmt.setInt(100); ResultSet rs= pstmt.executeQuery(); while(rs.next()) { InputStream in = rs.getBinaryStream(1); ... } rs.close();
No comments:
Post a Comment