| Revision | 88 (tree) |
|---|---|
| Time | 2015-08-23 14:53:51 |
| Author | t_nakayama1971 |
(empty log message)
| @@ -13,6 +13,7 @@ | ||
| 13 | 13 | |
| 14 | 14 | import org.apache.logging.log4j.LogManager; |
| 15 | 15 | |
| 16 | +import common.db.jdbc.Jdbc; | |
| 16 | 17 | import common.sql.QueryUtil; |
| 17 | 18 | import core.exception.PhysicalException; |
| 18 | 19 | import core.exception.ThrowableUtil; |
| @@ -40,7 +41,8 @@ | ||
| 40 | 41 | map.put("BatSeq", Integer.valueOf(dseq)); |
| 41 | 42 | |
| 42 | 43 | String query = QueryUtil.getSqlFromFile("SelectJobDetailStatus", this.getClass()); |
| 43 | - try (PreparedStatement psmt = QueryUtil.statementReadonly(conn, query, map)) { | |
| 44 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 45 | + query, map, Jdbc.wrap(conn)::readonlyStatement)) { | |
| 44 | 46 | JobDetail rec = null; |
| 45 | 47 | try (ResultSet rs = psmt.executeQuery()) { |
| 46 | 48 | if (rs.next()) { |
| @@ -69,8 +71,9 @@ | ||
| 69 | 71 | LogManager.getLogger().debug(query); |
| 70 | 72 | LogManager.getLogger().debug("jobseq={}", String.valueOf(seq)); |
| 71 | 73 | |
| 72 | - try (PreparedStatement psmt = QueryUtil.statementReadonly( | |
| 73 | - conn, query, Collections.singletonMap("JobSeq", Long.valueOf(seq)))) { | |
| 74 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 75 | + query, Collections.singletonMap("JobSeq", Long.valueOf(seq)), | |
| 76 | + Jdbc.wrap(conn)::readonlyStatement)) { | |
| 74 | 77 | List<JobDetail> list = new ArrayList<>(); |
| 75 | 78 | try (ResultSet rs = psmt.executeQuery()) { |
| 76 | 79 | while (rs.next()) { |
| @@ -107,7 +110,8 @@ | ||
| 107 | 110 | map.put("Message", msg); |
| 108 | 111 | |
| 109 | 112 | String query = QueryUtil.getSqlFromFile("UpdateJobDetail", this.getClass()); |
| 110 | - try (PreparedStatement psmt = QueryUtil.statementExecute(conn, query, map)) { | |
| 113 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 114 | + query, map, Jdbc.wrap(conn)::prepareStatement)) { | |
| 111 | 115 | // ジョブ詳細管理テーブル更新 |
| 112 | 116 | return psmt.executeUpdate(); |
| 113 | 117 |
| @@ -146,7 +150,8 @@ | ||
| 146 | 150 | map.put("BatName", name); |
| 147 | 151 | |
| 148 | 152 | String query = QueryUtil.getSqlFromFile("InsertJobDetail", this.getClass()); |
| 149 | - try (PreparedStatement psmt = QueryUtil.statementExecute(conn, query, map)) { | |
| 153 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 154 | + query, map, Jdbc.wrap(conn)::prepareStatement)) { | |
| 150 | 155 | // ジョブ管理テーブル更新 |
| 151 | 156 | int ret = psmt.executeUpdate(); |
| 152 | 157 | if (ret != 1) { |
| @@ -171,8 +176,9 @@ | ||
| 171 | 176 | public int deleteJobDetail(final Connection conn, final long seq) { |
| 172 | 177 | |
| 173 | 178 | String query = QueryUtil.getSqlFromFile("DeleteJobDetail", this.getClass()); |
| 174 | - try (PreparedStatement psmt = QueryUtil.statementExecute( | |
| 175 | - conn, query, Collections.singletonMap("JobSeq", Long.valueOf(seq)))) { | |
| 179 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 180 | + query, Collections.singletonMap("JobSeq", Long.valueOf(seq)), | |
| 181 | + Jdbc.wrap(conn)::prepareStatement)) { | |
| 176 | 182 | return psmt.executeUpdate(); |
| 177 | 183 | } catch (final SQLException ex) { |
| 178 | 184 | ThrowableUtil.error(ex); |
| @@ -10,7 +10,6 @@ | ||
| 10 | 10 | |
| 11 | 11 | import common.db.jdbc.Jdbc; |
| 12 | 12 | import common.sql.QueryUtil; |
| 13 | - | |
| 14 | 13 | import core.exception.PhysicalException; |
| 15 | 14 | import core.exception.ThrowableUtil; |
| 16 | 15 |
| @@ -32,8 +31,9 @@ | ||
| 32 | 31 | @Override |
| 33 | 32 | public JobMaster getJobMasterInfo(final Connection conn, final String jobid) { |
| 34 | 33 | String query = QueryUtil.getSqlFromFile("SelectJobInfo", this.getClass()); |
| 35 | - try (PreparedStatement psmt = QueryUtil.statementReadonly( | |
| 36 | - conn, query, Collections.singletonMap("JobId", jobid))) { | |
| 34 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 35 | + query, Collections.singletonMap("JobId", jobid), | |
| 36 | + Jdbc.wrap(conn)::readonlyStatement)) { | |
| 37 | 37 | JobMaster ret = null; |
| 38 | 38 | try (ResultSet rs = psmt.executeQuery()) { |
| 39 | 39 | if (rs.next()) { |
| @@ -14,6 +14,7 @@ | ||
| 14 | 14 | |
| 15 | 15 | import org.apache.logging.log4j.LogManager; |
| 16 | 16 | |
| 17 | +import common.db.jdbc.Jdbc; | |
| 17 | 18 | import common.sql.QueryUtil; |
| 18 | 19 | import core.exception.PhysicalException; |
| 19 | 20 | import core.exception.ThrowableUtil; |
| @@ -44,7 +45,8 @@ | ||
| 44 | 45 | map.put("BatSeq", Integer.valueOf(dseq)); |
| 45 | 46 | map.put("FileSeq", Integer.valueOf(fseq)); |
| 46 | 47 | |
| 47 | - try (PreparedStatement psmt = QueryUtil.statementReadonly(conn, query, map)) { | |
| 48 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 49 | + query, map, Jdbc.wrap(conn)::readonlyStatement)) { | |
| 48 | 50 | // ジョブ管理テーブル読み込み |
| 49 | 51 | JobFile ret = null; |
| 50 | 52 | try (ResultSet rs = psmt.executeQuery()) { |
| @@ -71,8 +73,9 @@ | ||
| 71 | 73 | public List<JobFile> selectJobFiles(final Connection conn, final long seq) { |
| 72 | 74 | |
| 73 | 75 | String query = QueryUtil.getSqlFromFile("SelectJobFileList", this.getClass()); |
| 74 | - try (PreparedStatement psmt = QueryUtil.statementReadonly( | |
| 75 | - conn, query, Collections.singletonMap("JobSeq", Long.valueOf(seq)))) { | |
| 76 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 77 | + query, Collections.singletonMap("JobSeq", Long.valueOf(seq)), | |
| 78 | + Jdbc.wrap(conn)::readonlyStatement)) { | |
| 76 | 79 | List<JobFile> ret = new ArrayList<>(); |
| 77 | 80 | try (ResultSet rs = psmt.executeQuery()) { |
| 78 | 81 | while (rs.next()) { |
| @@ -109,7 +112,8 @@ | ||
| 109 | 112 | map.put("FileSize", Long.valueOf(size)); |
| 110 | 113 | |
| 111 | 114 | String query = QueryUtil.getSqlFromFile("UpdateJobFile", this.getClass()); |
| 112 | - try (PreparedStatement psmt = QueryUtil.statementExecute(conn, query, map)) { | |
| 115 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 116 | + query, map, Jdbc.wrap(conn)::prepareStatement)) { | |
| 113 | 117 | return psmt.executeUpdate(); |
| 114 | 118 | } catch (final SQLException ex) { |
| 115 | 119 | ThrowableUtil.error(ex); |
| @@ -127,8 +131,9 @@ | ||
| 127 | 131 | @Override |
| 128 | 132 | public int deleteJobFile(final Connection conn, final long seq) { |
| 129 | 133 | String query = QueryUtil.getSqlFromFile("DeleteJobFile", this.getClass()); |
| 130 | - try (PreparedStatement psmt = QueryUtil.statementExecute( | |
| 131 | - conn, query, Collections.singletonMap("JobSeq", Long.valueOf(seq)))) { | |
| 134 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 135 | + query, Collections.singletonMap("JobSeq", Long.valueOf(seq)), | |
| 136 | + Jdbc.wrap(conn)::prepareStatement)) { | |
| 132 | 137 | // ファイル管理削除 |
| 133 | 138 | return psmt.executeUpdate(); |
| 134 | 139 | } catch (final SQLException ex) { |
| @@ -157,7 +162,8 @@ | ||
| 157 | 162 | map.put("Count", Integer.valueOf(0)); |
| 158 | 163 | |
| 159 | 164 | String query = QueryUtil.getSqlFromFile("InsertJobFile", this.getClass()); |
| 160 | - try (PreparedStatement psmt = QueryUtil.statementExecute(conn, query, map)) { | |
| 165 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 166 | + query, map, Jdbc.wrap(conn)::prepareStatement)) { | |
| 161 | 167 | // ファイル管理テーブル更新 |
| 162 | 168 | return psmt.executeUpdate(); |
| 163 | 169 | } catch (final SQLException ex) { |
| @@ -15,11 +15,9 @@ | ||
| 15 | 15 | import java.util.Objects; |
| 16 | 16 | |
| 17 | 17 | import batch.util.ParameterUtil; |
| 18 | - | |
| 19 | 18 | import common.db.jdbc.Jdbc; |
| 20 | 19 | import common.sql.QueryUtil; |
| 21 | 20 | import common.sql.QueryUtil.StatementCreator; |
| 22 | - | |
| 23 | 21 | import core.exception.PhysicalException; |
| 24 | 22 | import core.exception.ThrowableUtil; |
| 25 | 23 |
| @@ -73,7 +71,8 @@ | ||
| 73 | 71 | map.put("HostName", hostId); |
| 74 | 72 | |
| 75 | 73 | String query = QueryUtil.getSqlFromFile("SelectJobStatus", this.getClass()); |
| 76 | - try (PreparedStatement psmt = QueryUtil.statementReadonly(conn, query, map)) { | |
| 74 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 75 | + query, map, Jdbc.wrap(conn)::readonlyStatement)) { | |
| 77 | 76 | List<Job> l = new ArrayList<>(); |
| 78 | 77 | try (ResultSet rs = psmt.executeQuery()) { |
| 79 | 78 | while (rs.next()) { |
| @@ -99,8 +98,9 @@ | ||
| 99 | 98 | public Job getJobWithLock(final Connection conn, final long seq) { |
| 100 | 99 | |
| 101 | 100 | String query = QueryUtil.getSqlFromFile("SelectJobStatusById", this.getClass()); |
| 102 | - try (PreparedStatement psmt = QueryUtil.statementReadonly( | |
| 103 | - conn, query, Collections.singletonMap("JobSeq", Long.valueOf(seq)))) { | |
| 101 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 102 | + query, Collections.singletonMap("JobSeq", Long.valueOf(seq)), | |
| 103 | + Jdbc.wrap(conn)::readonlyStatement)) { | |
| 104 | 104 | Job ret = null; |
| 105 | 105 | try (ResultSet rs = psmt.executeQuery()) { |
| 106 | 106 | if (rs.next()) { |
| @@ -134,7 +134,8 @@ | ||
| 134 | 134 | map.put("JobSeq", Long.valueOf(seq)); |
| 135 | 135 | |
| 136 | 136 | String query = QueryUtil.getSqlFromFile("UpdateJobStatus", this.getClass()); |
| 137 | - try (PreparedStatement psmt = QueryUtil.statementExecute(conn, query, map)) { | |
| 137 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 138 | + query, map, Jdbc.wrap(conn)::prepareStatement)) { | |
| 138 | 139 | return psmt.executeUpdate(); |
| 139 | 140 | |
| 140 | 141 | } catch (final SQLException ex) { |
| @@ -160,7 +161,8 @@ | ||
| 160 | 161 | map.put("HostName", hostId); |
| 161 | 162 | |
| 162 | 163 | String query = QueryUtil.getSqlFromFile("SelectJobStatusList", this.getClass()); |
| 163 | - try (PreparedStatement psmt = QueryUtil.statementReadonly(conn, query, map)) { | |
| 164 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 165 | + query, map, Jdbc.wrap(conn)::readonlyStatement)) { | |
| 164 | 166 | // バッチ管理テーブル読み込み |
| 165 | 167 | List<Job> l = new ArrayList<>(); |
| 166 | 168 | try (ResultSet rs = psmt.executeQuery()) { |
| @@ -252,8 +254,9 @@ | ||
| 252 | 254 | public int deleteJob(final Connection conn, final long seq) { |
| 253 | 255 | |
| 254 | 256 | String query = QueryUtil.getSqlFromFile("DeleteJobStatus", this.getClass()); |
| 255 | - try (PreparedStatement psmt = QueryUtil.statementExecute( | |
| 256 | - conn, query, Collections.singletonMap("JobSeq", Long.valueOf(seq)))) { | |
| 257 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 258 | + query, Collections.singletonMap("JobSeq", Long.valueOf(seq)), | |
| 259 | + Jdbc.wrap(conn)::prepareStatement)) { | |
| 257 | 260 | return psmt.executeUpdate(); |
| 258 | 261 | } catch (final SQLException ex) { |
| 259 | 262 | ThrowableUtil.error(ex); |
| @@ -272,8 +275,9 @@ | ||
| 272 | 275 | public Job getJob(final Connection conn, final long seq) { |
| 273 | 276 | |
| 274 | 277 | String query = QueryUtil.getSqlFromFile("SelectJobStatusById", this.getClass()); |
| 275 | - try (PreparedStatement psmt = QueryUtil.statementReadonly( | |
| 276 | - conn, query, Collections.singletonMap("JobSeq", Long.valueOf(seq)))) { | |
| 278 | + try (PreparedStatement psmt = QueryUtil.createStatement( | |
| 279 | + query, Collections.singletonMap("JobSeq", Long.valueOf(seq)), | |
| 280 | + Jdbc.wrap(conn)::readonlyStatement)) { | |
| 277 | 281 | // ジョブ管理テーブル読み込み |
| 278 | 282 | Job ret = null; |
| 279 | 283 | try (ResultSet rs = psmt.executeQuery()) { |