📄 oracledelegate.java
字号:
ps = conn.prepareStatement(rtp(UPDATE_ORACLE_JOB_DETAIL)); ps.setString(1, job.getDescription()); ps.setString(2, job.getJobClass().getName()); ps.setBoolean(3, job.isDurable()); ps.setBoolean(4, job.isVolatile()); ps.setBoolean(5, job.isStateful()); ps.setBoolean(6, job.requestsRecovery()); ps.setString(7, job.getName()); ps.setString(8, job.getGroup()); ps.executeUpdate(); ps.close(); ps = conn .prepareStatement(rtp(UPDATE_ORACLE_JOB_DETAIL_EMPTY_BLOB)); ps.setString(1, job.getName()); ps.setString(2, job.getGroup()); ps.executeUpdate(); ps.close(); ps = conn.prepareStatement(rtp(SELECT_ORACLE_JOB_DETAIL_BLOB)); ps.setString(1, job.getName()); ps.setString(2, job.getGroup()); rs = ps.executeQuery(); int res = 0; if (rs.next()) { Blob dbBlob = writeDataToBlob(rs, 1, data); ps2 = conn.prepareStatement(rtp(UPDATE_ORACLE_JOB_DETAIL_BLOB)); ps2.setBlob(1, dbBlob); ps2.setString(2, job.getName()); ps2.setString(3, job.getGroup()); res = ps2.executeUpdate(); } if (res > 0) { deleteJobListeners(conn, job.getName(), job.getGroup()); String[] jobListeners = job.getJobListenerNames(); for (int i = 0; jobListeners != null && i < jobListeners.length; i++) insertJobListener(conn, job, jobListeners[i]); } return res; } finally { if (null != rs) { try { rs.close(); } catch (SQLException ignore) { } } if (null != ps) { try { ps.close(); } catch (SQLException ignore) { } } if (null != ps2) { try { ps2.close(); } catch (SQLException ignore) { } } } } public int insertCalendar(Connection conn, String calendarName, Calendar calendar) throws IOException, SQLException { ByteArrayOutputStream baos = serializeObject(calendar); PreparedStatement ps = null; PreparedStatement ps2 = null; ResultSet rs = null; try { ps = conn.prepareStatement(rtp(INSERT_ORACLE_CALENDAR)); ps.setString(1, calendarName); ps.executeUpdate(); ps.close(); ps = conn.prepareStatement(rtp(SELECT_ORACLE_CALENDAR_BLOB)); ps.setString(1, calendarName); rs = ps.executeQuery(); if (rs.next()) { Blob dbBlob = writeDataToBlob(rs, 1, baos.toByteArray()); ps2 = conn.prepareStatement(rtp(UPDATE_ORACLE_CALENDAR_BLOB)); ps2.setBlob(1, dbBlob); ps2.setString(2, calendarName); return ps2.executeUpdate(); } return 0; } finally { if (null != rs) { try { rs.close(); } catch (SQLException ignore) { } } if (null != ps) { try { ps.close(); } catch (SQLException ignore) { } } if (null != ps2) { try { ps2.close(); } catch (SQLException ignore) { } } } } public int updateCalendar(Connection conn, String calendarName, Calendar calendar) throws IOException, SQLException { ByteArrayOutputStream baos = serializeObject(calendar); PreparedStatement ps = null; PreparedStatement ps2 = null; ResultSet rs = null; try { ps = conn.prepareStatement(rtp(SELECT_ORACLE_CALENDAR_BLOB)); ps.setString(1, calendarName); rs = ps.executeQuery(); if (rs.next()) { Blob dbBlob = writeDataToBlob(rs, 1, baos.toByteArray()); ps2 = conn.prepareStatement(rtp(UPDATE_ORACLE_CALENDAR_BLOB)); ps2.setBlob(1, dbBlob); ps2.setString(2, calendarName); return ps2.executeUpdate(); } return 0; } finally { if (null != rs) { try { rs.close(); } catch (SQLException ignore) { } } if (null != ps) { try { ps.close(); } catch (SQLException ignore) { } } if (null != ps2) { try { ps2.close(); } catch (SQLException ignore) { } } } } public int updateJobData(Connection conn, JobDetail job) throws IOException, SQLException { ByteArrayOutputStream baos = serializeJobData(job.getJobDataMap()); byte[] data = baos.toByteArray(); PreparedStatement ps = null; PreparedStatement ps2 = null; ResultSet rs = null; try { ps = conn.prepareStatement(rtp(SELECT_ORACLE_JOB_DETAIL_BLOB)); ps.setString(1, job.getName()); ps.setString(2, job.getGroup()); rs = ps.executeQuery(); int res = 0; if (rs.next()) { Blob dbBlob = writeDataToBlob(rs, 1, data); ps2 = conn.prepareStatement(rtp(UPDATE_ORACLE_JOB_DETAIL_BLOB)); ps2.setBlob(1, dbBlob); ps2.setString(2, job.getName()); ps2.setString(3, job.getGroup()); res = ps2.executeUpdate(); } return res; } finally { if (null != rs) { try { rs.close(); } catch (SQLException ignore) { } } if (null != ps) { try { ps.close(); } catch (SQLException ignore) { } } if (null != ps2) { try { ps2.close(); } catch (SQLException ignore) { } } } } protected Blob writeDataToBlob(ResultSet rs, int column, byte[] data) throws SQLException { Blob blob = rs.getBlob(column); // get blob if(blob == null) throw new SQLException("Driver's Blob representation is null!"); if (blob instanceof oracle.sql.BLOB) { // is it an oracle blob? ((oracle.sql.BLOB) blob).putBytes(1, data); return blob; } else { throw new SQLException( "Driver's Blob representation is of an unsupported type: " + blob.getClass().getName()); } }}// EOF
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -