Blob
Blob (SQL BLOB 매핑)
SQL BLOB 값을 Java 프로그래밍 언어로 표현(매핑)한 것입니다. SQL BLOB은 데이터베이스 테이블 행의 열 값으로 Binary Large Object를 저장하는 내장 타입이에요.
본문
기본적으로 드라이버는 SQL locator(BLOB)를 사용해 Blob을 구현하며, 이는 Blob 객체가 BLOB 데이터 자체가 아니라 BLOB 데이터에 대한 논리적 포인터를 담음을 뜻합니다. Blob 객체는 생성된 트랜잭션 기간 동안 유효해요.
ResultSet, CallableStatement, PreparedStatement 인터페이스의 getBlob, setBlob 같은 메서드를 사용해 SQL BLOB 값에 접근할 수 있습니다. Blob 인터페이스는 BLOB 값의 길이를 얻고, BLOB 값을 클라이언트에 materialize하고, BLOB 값 내에서 바이트 패턴의 위치를 찾는 메서드를 제공하며, BLOB 값을 갱신하는 메서드도 포함합니다.
JDBC 드라이버가 이 데이터 타입을 지원한다면 Blob 인터페이스의 모든 메서드를 완전히 구현해야 합니다.
대표적인 메서드
long length() throws SQLException
byte[] getBytes(long pos, int length) throws SQLException
InputStream getBinaryStream() throws SQLException
long position(byte[] pattern, long start) throws SQLException
int setBytes(long pos, byte[] bytes) throws SQLException
void truncate(long len) throws SQLException
void free() throws SQLException