[jboss-user] [jBPM] - Re: How get completed/release time for a task?
Nick Tan
do-not-reply at jboss.com
Mon Jun 27 23:10:59 EDT 2011
Nick Tan [http://community.jboss.org/people/missedone] created the discussion
"Re: How get completed/release time for a task?"
To view the discussion, visit: http://community.jboss.org/message/612246#612246
--------------------------------------------------------------
Thanks, Jose
finally, i use jdbc directly since i want to have as less dependency as possible, but obviously the limition is it tightly couple with postgresql driver classes
| | /** |
| | * get the content bytearray with PostgreSQL JDBC driver |
| | * |
| | * @param contentId |
| | * @return the content byte array, or <code>null</code> if not found |
| | * @see http://snipplr.com/view/53917/postgres-how-to-read-oid-value-using-jdbc-api/ |
| | * | http://virgo47.wordpress.com/2008/06/13/jpa-postgresql-and-bytea-vs-oid-type/ |
| | */ |
| | public byte[] getContentWithPg(long contentId) { |
| | | Connection conn = null; |
| | | PreparedStatement stmt = null; |
| | | try { |
| | | | conn = getConnection(); |
| | | | conn.setAutoCommit(false); |
| | | | // Get the Large Object Manager to perform operations with |
| | | | LargeObjectManager lobj = ((org.postgresql.PGConnection) conn).getLargeObjectAPI(); |
| | | | stmt = conn.prepareStatement("SELECT content FROM content WHERE id = ?"); |
| | | | stmt.setLong(1, contentId); |
| | | | ResultSet rs = stmt.executeQuery(); |
| | | | if (rs != null) { |
| | | | | if (rs.next()) { |
| | | | | | // Open the large object for reading |
| | | | | | long oid = rs.getLong(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(); |
| | | | | | return buf; |
| | | | | } |
| | | | | rs.close(); |
| | | | } |
| | | | conn.commit(); |
| | | } |
| | | catch (Exception e) { |
| | | | e.printStackTrace(); |
| | | } |
| | | finally { |
| | | | try { |
| | | | | if (conn != null) |
| | | | | | conn.close(); |
| | | | | if (stmt != null) |
| | | | | | stmt.close(); |
| | | | } |
| | | | catch (SQLException e) { |
| | | | | e.printStackTrace(); |
| | | | } |
| | | } |
| | | return null; |
| | } |
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/612246#612246]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110627/d5dd1f46/attachment.html
More information about the jboss-user
mailing list