|
28 | 28 |
|
29 | 29 | import javax.sql.DataSource; |
30 | 30 |
|
| 31 | +import org.apache.commons.dbutils.constants.SQLExceptionCostants; |
| 32 | + |
31 | 33 | /** |
32 | 34 | * Executes SQL queries with pluggable strategies for handling |
33 | 35 | * {@code ResultSet}s. This class is thread safe. |
@@ -131,15 +133,15 @@ public QueryRunner(final StatementConfiguration stmtConfig) { |
131 | 133 | */ |
132 | 134 | public int[] batch(final Connection conn, final String sql, final Object[][] params) throws SQLException { |
133 | 135 | if (conn == null) { |
134 | | - throw new SQLException("Null connection"); |
| 136 | + throw new SQLException(SQLExceptionCostants.NULL_CONNECTION_ERROR); |
135 | 137 | } |
136 | 138 |
|
137 | 139 | if (sql == null) { |
138 | | - throw new SQLException("Null SQL statement"); |
| 140 | + throw new SQLException(SQLExceptionCostants.NULL_STATEMENT_ERROR); |
139 | 141 | } |
140 | 142 |
|
141 | 143 | if (params == null) { |
142 | | - throw new SQLException("Null parameters. If parameters aren't need, pass an empty array."); |
| 144 | + throw new SQLException(SQLExceptionCostants.NULL_PARAMS_ERROR); |
143 | 145 | } |
144 | 146 |
|
145 | 147 | PreparedStatement stmt = null; |
@@ -206,11 +208,11 @@ public int[] batch(final String sql, final Object[][] params) throws SQLExceptio |
206 | 208 | */ |
207 | 209 | public int execute(final Connection conn, final String sql, final Object... params) throws SQLException { |
208 | 210 | if (conn == null) { |
209 | | - throw new SQLException("Null connection"); |
| 211 | + throw new SQLException(SQLExceptionCostants.NULL_CONNECTION_ERROR); |
210 | 212 | } |
211 | 213 |
|
212 | 214 | if (sql == null) { |
213 | | - throw new SQLException("Null SQL statement"); |
| 215 | + throw new SQLException(SQLExceptionCostants.NULL_STATEMENT_ERROR); |
214 | 216 | } |
215 | 217 |
|
216 | 218 | CallableStatement stmt = null; |
@@ -257,15 +259,15 @@ public int execute(final Connection conn, final String sql, final Object... para |
257 | 259 | */ |
258 | 260 | public <T> List<T> execute(final Connection conn, final String sql, final ResultSetHandler<T> rsh, final Object... params) throws SQLException { |
259 | 261 | if (conn == null) { |
260 | | - throw new SQLException("Null connection"); |
| 262 | + throw new SQLException(SQLExceptionCostants.NULL_CONNECTION_ERROR); |
261 | 263 | } |
262 | 264 |
|
263 | 265 | if (sql == null) { |
264 | | - throw new SQLException("Null SQL statement"); |
| 266 | + throw new SQLException(SQLExceptionCostants.NULL_STATEMENT_ERROR); |
265 | 267 | } |
266 | 268 |
|
267 | 269 | if (rsh == null) { |
268 | | - throw new SQLException("Null ResultSetHandler"); |
| 270 | + throw new SQLException(SQLExceptionCostants.NULL_RESULT_SET_ERROR); |
269 | 271 | } |
270 | 272 |
|
271 | 273 | CallableStatement stmt = null; |
@@ -381,15 +383,15 @@ public <T> T insert(final Connection conn, final String sql, final ResultSetHand |
381 | 383 | */ |
382 | 384 | public <T> T insert(final Connection conn, final String sql, final ResultSetHandler<T> rsh, final Object... params) throws SQLException { |
383 | 385 | if (conn == null) { |
384 | | - throw new SQLException("Null connection"); |
| 386 | + throw new SQLException(SQLExceptionCostants.NULL_CONNECTION_ERROR); |
385 | 387 | } |
386 | 388 |
|
387 | 389 | if (sql == null) { |
388 | | - throw new SQLException("Null SQL statement"); |
| 390 | + throw new SQLException(SQLExceptionCostants.NULL_STATEMENT_ERROR); |
389 | 391 | } |
390 | 392 |
|
391 | 393 | if (rsh == null) { |
392 | | - throw new SQLException("Null ResultSetHandler"); |
| 394 | + throw new SQLException(SQLExceptionCostants.NULL_RESULT_SET_ERROR); |
393 | 395 | } |
394 | 396 |
|
395 | 397 | Statement stmt = null; |
@@ -469,15 +471,15 @@ public <T> T insert(final String sql, final ResultSetHandler<T> rsh, final Objec |
469 | 471 | */ |
470 | 472 | public <T> T insertBatch(final Connection conn, final String sql, final ResultSetHandler<T> rsh, final Object[][] params) throws SQLException { |
471 | 473 | if (conn == null) { |
472 | | - throw new SQLException("Null connection"); |
| 474 | + throw new SQLException(SQLExceptionCostants.NULL_CONNECTION_ERROR); |
473 | 475 | } |
474 | 476 |
|
475 | 477 | if (sql == null) { |
476 | | - throw new SQLException("Null SQL statement"); |
| 478 | + throw new SQLException(SQLExceptionCostants.NULL_STATEMENT_ERROR); |
477 | 479 | } |
478 | 480 |
|
479 | 481 | if (params == null) { |
480 | | - throw new SQLException("Null parameters. If parameters aren't need, pass an empty array."); |
| 482 | + throw new SQLException(SQLExceptionCostants.NULL_PARAMS_ERROR); |
481 | 483 | } |
482 | 484 |
|
483 | 485 | PreparedStatement stmt = null; |
@@ -583,15 +585,15 @@ public <T> T query(final Connection conn, final String sql, final ResultSetHandl |
583 | 585 | */ |
584 | 586 | public <T> T query(final Connection conn, final String sql, final ResultSetHandler<T> rsh, final Object... params) throws SQLException { |
585 | 587 | if (conn == null) { |
586 | | - throw new SQLException("Null connection"); |
| 588 | + throw new SQLException(SQLExceptionCostants.NULL_CONNECTION_ERROR); |
587 | 589 | } |
588 | 590 |
|
589 | 591 | if (sql == null) { |
590 | | - throw new SQLException("Null SQL statement"); |
| 592 | + throw new SQLException(SQLExceptionCostants.NULL_STATEMENT_ERROR); |
591 | 593 | } |
592 | 594 |
|
593 | 595 | if (rsh == null) { |
594 | | - throw new SQLException("Null ResultSetHandler"); |
| 596 | + throw new SQLException(SQLExceptionCostants.NULL_RESULT_SET_ERROR); |
595 | 597 | } |
596 | 598 |
|
597 | 599 | Statement stmt = null; |
@@ -759,11 +761,11 @@ public int update(final Connection conn, final String sql, final Object param) t |
759 | 761 | */ |
760 | 762 | public int update(final Connection conn, final String sql, final Object... params) throws SQLException { |
761 | 763 | if (conn == null) { |
762 | | - throw new SQLException("Null connection"); |
| 764 | + throw new SQLException(SQLExceptionCostants.NULL_CONNECTION_ERROR); |
763 | 765 | } |
764 | 766 |
|
765 | 767 | if (sql == null) { |
766 | | - throw new SQLException("Null SQL statement"); |
| 768 | + throw new SQLException(SQLExceptionCostants.NULL_STATEMENT_ERROR); |
767 | 769 | } |
768 | 770 |
|
769 | 771 | Statement stmt = null; |
|
0 commit comments