- con = theStorageObject.getPooledCon();
- con.setAutoCommit(false);
- LargeObjectManager lom;
- java.sql.Connection jCon;
- stmt = con.createStatement();
- ResultSet rs = theStorageObject.executeSql(stmt,
- "select icon_data from images where id="+getId());
- jCon = ((com.codestudio.sql.PoolManConnectionHandle)con)
- .getNativeConnection();
- lom = ((org.postgresql.Connection)jCon).getLargeObjectAPI();
- if(rs!=null) {
- if (rs.next()) {
- LargeObject lob = lom.open(rs.getInt(1));
- in = (BlobInputStream)lob.getInputStream();
- img_in = new ImageInputStream( in, con ,stmt);
- //img_data = rs.getBytes(1);
- }
- rs.close();
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- theLog.printError("EntityImages -- getIcon failed"+e.toString());
- try {
- con.setAutoCommit(true);
- }
- catch (Exception e2) {
- e.printStackTrace();
- theLog.printError(
- "EntityImages -- getIcon reseting transaction mode failed"
- +e2.toString());
- }
- theStorageObject.freeConnection(con,stmt);
- throwStorageObjectException(e, "EntityImages -- getIcon failed:");
- }
-
- return img_in;
- }
-
- /**
- * a small wrapper class that allows us to store the DB connection resources
- * that the BlobInputStream is using and free them upon closing of the stream
- */
- private class ImageInputStream extends InputStream {
-
- InputStream _in;
- java.sql.Connection _con;
- Statement _stmt;
-
- public ImageInputStream(BlobInputStream in, java.sql.Connection con,
- Statement stmt )
- {
- _in = in;
- _con = con;
- _stmt = stmt;