com.amazon.redshift.jdbc.RedshiftBlob Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redshift-jdbc42 Show documentation
Show all versions of redshift-jdbc42 Show documentation
Java JDBC 4.2 (JRE 8+) driver for Redshift database
The newest version!
/*
* Copyright (c) 2004, PostgreSQL Global Development Group
* See the LICENSE file in the project root for more information.
*/
package com.amazon.redshift.jdbc;
import com.amazon.redshift.largeobject.LargeObject;
import java.sql.SQLException;
public class RedshiftBlob extends AbstractBlobClob implements java.sql.Blob {
public RedshiftBlob(com.amazon.redshift.core.BaseConnection conn, long oid) throws SQLException {
super(conn, oid);
}
public synchronized java.io.InputStream getBinaryStream(long pos, long length)
throws SQLException {
checkFreed();
LargeObject subLO = getLo(false).copy();
addSubLO(subLO);
if (pos > Integer.MAX_VALUE) {
subLO.seek64(pos - 1, LargeObject.SEEK_SET);
} else {
subLO.seek((int) pos - 1, LargeObject.SEEK_SET);
}
return subLO.getInputStream(length);
}
public synchronized int setBytes(long pos, byte[] bytes) throws SQLException {
return setBytes(pos, bytes, 0, bytes.length);
}
public synchronized int setBytes(long pos, byte[] bytes, int offset, int len)
throws SQLException {
assertPosition(pos);
getLo(true).seek((int) (pos - 1));
getLo(true).write(bytes, offset, len);
return len;
}
}