Revision: 46569
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 21, 2011 16:02 by arunpjohny
Initial Code
conn.setAutoCommit(false);
// Get the Large Object Manager to perform operations with
LargeObjectManager lobj = ((org.postgresql.PGConnection)conn).getLargeObjectAPI();
PreparedStatement ps = con.prepareStatement("SELECT imgoid FROM imageslo WHERE imgname = ?");
ps.setString(1, "myimage.gif");
ResultSet rs = ps.executeQuery();
if (rs != null) {
while (rs.next()) {
// Open the large object for reading
int oid = rs.getInt(1);
LargeObject obj = lobj.open(oid, LargeObjectManager.READ);
// Read the data
byte buf[] = new byte[obj.size()];
obj.read(buf, 0, obj.size());
// Do something with the data read here
// Close the object
obj.close();
}
rs.close();
}
ps.close();
conn.commit();
Initial URL
http://www.postgresql.org/docs/7.4/static/jdbc-binary-data.html
Initial Description
Initial Title
Postgres: How to read oid value using JDBC API
Initial Tags
Initial Language
Java