1 17 18 21 package org.quartz.impl.jdbcjobstore; 22 23 import java.io.ByteArrayInputStream ; 24 import java.io.IOException ; 25 import java.io.InputStream ; 26 import java.io.ObjectInputStream ; 27 import java.sql.ResultSet ; 28 import java.sql.SQLException ; 29 30 import org.apache.commons.logging.Log; 31 32 39 public class PostgreSQLDelegate extends StdJDBCDelegate { 40 50 public PostgreSQLDelegate(Log log, String tablePrefix, String instanceId) { 51 super(log, tablePrefix, instanceId); 52 } 53 54 66 public PostgreSQLDelegate(Log log, String tablePrefix, String instanceId, 67 Boolean useProperties) { 68 super(log, tablePrefix, instanceId, useProperties); 69 } 70 71 75 92 protected Object getObjectFromBlob(ResultSet rs, String colName) 93 throws ClassNotFoundException , IOException , SQLException { 94 InputStream binaryInput = null; 95 byte[] bytes = rs.getBytes(colName); 96 97 Object obj = null; 98 99 if(bytes != null && bytes.length != 0) { 100 binaryInput = new ByteArrayInputStream (bytes); 101 102 ObjectInputStream in = new ObjectInputStream (binaryInput); 103 try { 104 obj = in.readObject(); 105 } finally { 106 in.close(); 107 } 108 109 } 110 111 return obj; 112 } 113 114 protected Object getJobDetailFromBlob(ResultSet rs, String colName) 115 throws ClassNotFoundException , IOException , SQLException { 116 if (canUseProperties()) { 117 InputStream binaryInput = null; 118 byte[] bytes = rs.getBytes(colName); 119 if(bytes == null || bytes.length == 0) { 120 return null; 121 } 122 binaryInput = new ByteArrayInputStream (bytes); 123 return binaryInput; 124 } 125 return getObjectFromBlob(rs, colName); 126 } 127 } 128 129 | Popular Tags |