本文整理汇总了Java中org.postgresql.largeobject.LargeObject类的典型用法代码示例。如果您正苦于以下问题:Java LargeObject类的具体用法?Java LargeObject怎么用?Java LargeObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LargeObject类属于org.postgresql.largeobject包,在下文中一共展示了LargeObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getPostgreSqlnputStream
import org.postgresql.largeobject.LargeObject; //导入依赖的package包/类
/**
* 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;
}
开发者ID:kawansoft,项目名称:aceql-http,代码行数:31,代码来源:PostgreSqlUtil.java
示例2: setPostgreSqlParameterWithLargeObject
import org.postgresql.largeobject.LargeObject; //导入依赖的package包/类
/**
* Create a Large Object to set the PostgreSQL OID with
*
* @param preparedStatement
* the Prepared Statement
* @param parameterIndex
* the parameter index
* @param in
* The Input Stream to use
* @param connection
* the JDBC Connection
* @throws SQLException
* @throws IOException
*/
public static void setPostgreSqlParameterWithLargeObject(
PreparedStatement preparedStatement, int parameterIndex,
InputStream in, Connection connection) throws SQLException,
IOException {
// Get the Large Object Manager to perform operations with
LargeObjectManager lobj = ((org.postgresql.PGConnection) connection)
.getLargeObjectAPI();
// Create a new large object
long oid = lobj.createLO(LargeObjectManager.READ
| LargeObjectManager.WRITE);
// Open the large object for writing
LargeObject obj = lobj.open(oid, LargeObjectManager.WRITE);
try (OutputStream out = obj.getOutputStream();){
IOUtils.copy(in, out);
} finally {
//IOUtils.closeQuietly(out);
// Close the large object
obj.close();
}
preparedStatement.setLong(parameterIndex, oid);
}
开发者ID:kawansoft,项目名称:aceql-http,代码行数:40,代码来源:PostgreSqlUtil.java
示例3: writeToFile
import org.postgresql.largeobject.LargeObject; //导入依赖的package包/类
@Override
public int writeToFile(JDBCSequentialFile file, byte[] data) throws SQLException {
synchronized (connection) {
LargeObjectManager lobjManager = ((PGConnection) connection).getLargeObjectAPI();
LargeObject largeObject = null;
Long oid = getOID(file);
try {
connection.setAutoCommit(false);
largeObject = lobjManager.open(oid, LargeObjectManager.WRITE);
largeObject.seek(largeObject.size());
largeObject.write(data);
largeObject.close();
connection.commit();
} catch (Exception e) {
connection.rollback();
throw e;
}
return data.length;
}
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:PostgresSequentialSequentialFileDriver.java
示例4: getPostGresLargeObjectSize
import org.postgresql.largeobject.LargeObject; //导入依赖的package包/类
private int getPostGresLargeObjectSize(JDBCSequentialFile file) throws SQLException {
LargeObjectManager lobjManager = ((PGConnection) connection).getLargeObjectAPI();
int size = 0;
Long oid = getOID(file);
if (oid != null) {
synchronized (connection) {
try {
connection.setAutoCommit(false);
LargeObject largeObject = lobjManager.open(oid, LargeObjectManager.READ);
size = largeObject.size();
largeObject.close();
connection.commit();
} catch (SQLException e) {
connection.rollback();
throw e;
}
}
}
return size;
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:22,代码来源:PostgresSequentialSequentialFileDriver.java
示例5: doWritePostgres
import org.postgresql.largeobject.LargeObject; //导入依赖的package包/类
private void doWritePostgres(Handle h, String id, InputStream file) {
doDelete(h, id);
try {
LargeObjectManager lobj = getPostgresConnection(h.getConnection()).getLargeObjectAPI();
long oid = lobj.createLO();
LargeObject obj = lobj.open(oid, LargeObjectManager.WRITE);
try (OutputStream lob = obj.getOutputStream()) {
IOUtils.copy(file, lob);
}
h.insert("INSERT INTO icon_filestore(id, data) values (?,?)", id, oid);
} catch (IOException | SQLException ex) {
throw IconDataAccessException.launderThrowable(ex);
}
}
开发者ID:syndesisio,项目名称:syndesis,代码行数:16,代码来源:SqlIconFileStore.java
示例6: doReadPostgres
import org.postgresql.largeobject.LargeObject; //导入依赖的package包/类
/**
* Postgres does not allow to read from the large object after the connection has been closed.
*/
private InputStream doReadPostgres(String id) {
Handle h = dbi.open();
try {
h.getConnection().setAutoCommit(false);
List<Map<String, Object>> res = h.select("SELECT data FROM icon_filestore WHERE id=?", id);
Optional<Long> oid = res.stream()
.map(row -> row.get("data"))
.map(Long.class::cast)
.findFirst();
if (oid.isPresent()) {
LargeObjectManager lobj = getPostgresConnection(h.getConnection()).getLargeObjectAPI();
LargeObject obj = lobj.open(oid.get(), LargeObjectManager.READ);
return new HandleCloserInputStream(h, obj.getInputStream());
} else {
h.close();
return null;
}
} catch (SQLException e) {
IOUtils.closeQuietly(h);
throw IconDataAccessException.launderThrowable(e);
}
}
开发者ID:syndesisio,项目名称:syndesis,代码行数:30,代码来源:SqlIconFileStore.java
示例7: doWritePostgres
import org.postgresql.largeobject.LargeObject; //导入依赖的package包/类
private void doWritePostgres(Handle h, String path, InputStream file) {
doDelete(h, path);
try {
LargeObjectManager lobj = getPostgresConnection(h.getConnection()).getLargeObjectAPI();
long oid = lobj.createLO();
LargeObject obj = lobj.open(oid, LargeObjectManager.WRITE);
try (OutputStream lob = obj.getOutputStream()) {
IOUtils.copy(file, lob);
}
h.insert("INSERT INTO filestore(path, data) values (?,?)", path, oid);
} catch (IOException | SQLException ex) {
throw ExtensionDataAccessException.launderThrowable(ex);
}
}
开发者ID:syndesisio,项目名称:syndesis,代码行数:16,代码来源:SqlExtensionFileStore.java
示例8: doReadPostgres
import org.postgresql.largeobject.LargeObject; //导入依赖的package包/类
/**
* Postgres does not allow to read from the large object after the connection has been closed.
*/
private InputStream doReadPostgres(String path) {
Handle h = dbi.open();
try {
h.getConnection().setAutoCommit(false);
List<Map<String, Object>> res = h.select("SELECT data FROM filestore WHERE path=?", path);
Optional<Long> oid = res.stream()
.map(row -> row.get("data"))
.map(Long.class::cast)
.findFirst();
if (oid.isPresent()) {
LargeObjectManager lobj = getPostgresConnection(h.getConnection()).getLargeObjectAPI();
LargeObject obj = lobj.open(oid.get(), LargeObjectManager.READ);
return new HandleCloserInputStream(h, obj.getInputStream());
} else {
h.close();
return null;
}
} catch (SQLException e) {
IOUtils.closeQuietly(h);
throw ExtensionDataAccessException.launderThrowable(e);
}
}
开发者ID:syndesisio,项目名称:syndesis,代码行数:30,代码来源:SqlExtensionFileStore.java
示例9: doWritePostgres
import org.postgresql.largeobject.LargeObject; //导入依赖的package包/类
private void doWritePostgres(Handle h, String path, InputStream file) {
doDelete(h, path);
try {
LargeObjectManager lobj = getPostgresConnection(h.getConnection()).getLargeObjectAPI();
long oid = lobj.createLO();
LargeObject obj = lobj.open(oid, LargeObjectManager.WRITE);
try (OutputStream lob = obj.getOutputStream()) {
IOUtils.copy(file, lob);
}
h.insert("INSERT INTO filestore(path, data) values (?,?)", path, oid);
} catch (IOException | SQLException ex) {
throw FileStoreException.launderThrowable(ex);
}
}
开发者ID:syndesisio,项目名称:syndesis-rest,代码行数:16,代码来源:SqlFileStore.java
示例10: doReadPostgres
import org.postgresql.largeobject.LargeObject; //导入依赖的package包/类
/**
* Postgres does not allow to read from the large object after the connection has been closed.
*/
private InputStream doReadPostgres(String path) {
Handle h = dbi.open();
try {
h.getConnection().setAutoCommit(false);
List<Map<String, Object>> res = h.select("SELECT data FROM filestore WHERE path=?", path);
Optional<Long> oid = res.stream()
.map(row -> row.get("data"))
.map(Long.class::cast)
.findFirst();
if (oid.isPresent()) {
LargeObjectManager lobj = getPostgresConnection(h.getConnection()).getLargeObjectAPI();
LargeObject obj = lobj.open(oid.get(), LargeObjectManager.READ);
return new HandleCloserInputStream(h, obj.getInputStream());
} else {
h.close();
return null;
}
} catch (SQLException e) {
IOUtils.closeQuietly(h);
throw FileStoreException.launderThrowable(e);
}
}
开发者ID:syndesisio,项目名称:syndesis-rest,代码行数:30,代码来源:SqlFileStore.java
示例11: readFromFile
import org.postgresql.largeobject.LargeObject; //导入依赖的package包/类
@Override
public int readFromFile(JDBCSequentialFile file, ByteBuffer bytes) throws SQLException {
LargeObjectManager lobjManager = ((PGConnection) connection).getLargeObjectAPI();
LargeObject largeObject = null;
long oid = getOID(file);
synchronized (connection) {
try {
connection.setAutoCommit(false);
largeObject = lobjManager.open(oid, LargeObjectManager.READ);
int readLength = (int) calculateReadLength(largeObject.size(), bytes.remaining(), file.position());
if (readLength > 0) {
if (file.position() > 0)
largeObject.seek((int) file.position());
byte[] data = largeObject.read(readLength);
bytes.put(data);
}
largeObject.close();
connection.commit();
return readLength;
} catch (SQLException e) {
connection.rollback();
throw e;
}
}
}
开发者ID:apache,项目名称:activemq-artemis,代码行数:29,代码来源:PostgresSequentialSequentialFileDriver.java
示例12: free
import org.postgresql.largeobject.LargeObject; //导入依赖的package包/类
public synchronized void free() throws SQLException
{
if (lo != null) {
lo.close();
lo = null;
}
Iterator i = subLOs.iterator();
while (i.hasNext()) {
LargeObject subLO = (LargeObject)i.next();
subLO.close();
}
subLOs = null;
}
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:14,代码来源:AbstractJdbc2BlobClob.java
示例13: getBinaryStream
import org.postgresql.largeobject.LargeObject; //导入依赖的package包/类
public synchronized InputStream getBinaryStream() throws SQLException
{
checkFreed();
LargeObject subLO = lo.copy();
subLOs.add(subLO);
subLO.seek(0, LargeObject.SEEK_SET);
return subLO.getInputStream();
}
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:9,代码来源:AbstractJdbc2BlobClob.java
示例14: setBinaryStream
import org.postgresql.largeobject.LargeObject; //导入依赖的package包/类
public synchronized OutputStream setBinaryStream(long pos) throws SQLException
{
assertPosition(pos);
LargeObject subLO = lo.copy();
subLOs.add(subLO);
subLO.seek((int)(pos-1));
return subLO.getOutputStream();
}
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:9,代码来源:AbstractJdbc2BlobClob.java
示例15: getBytes
import org.postgresql.largeobject.LargeObject; //导入依赖的package包/类
public synchronized byte[] getBytes(long pos, int length) throws SQLException
{
assertPosition(pos);
lo.seek((int)(pos-1), LargeObject.SEEK_SET);
return lo.read(length);
}
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:7,代码来源:AbstractJdbc2BlobClob.java
注:本文中的org.postgresql.largeobject.LargeObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论