Prepares a statement, setting its fields to the elements of the vararg passed @param query The SQL query to prepare @param fields A vararg of the fields to set in the prepared statement @return The PreparedStatement with its fields set
(String query, Object... fields)
| 473 | * @return The PreparedStatement with its fields set |
| 474 | */ |
| 475 | public PreparedStatement prepareStatement(String query, Object... fields) { |
| 476 | try { |
| 477 | PreparedStatement statement = connection.prepareStatement(query); |
| 478 | int i = 1; |
| 479 | for (Object object : fields) { |
| 480 | statement.setObject(i, object); |
| 481 | i++; |
| 482 | } |
| 483 | return statement; |
| 484 | } catch (SQLException e) { |
| 485 | sneakyThrow(e); |
| 486 | return null; |
| 487 | } |
| 488 | } |
| 489 | |
| 490 | /** |
| 491 | * Closes the underlying connection this SQLHelper wraps |
no test coverage detected