Executes a SQL query as a prepared statement, setting its fields to the elements of the vararg passed, returning the value in the first column of the first row in the results as a Long. @param query The SQL query to execute @param fields A vararg of the fields to set in the prepared statement @ret
(String query, Object... fields)
| 314 | * column can be parsed into one. |
| 315 | */ |
| 316 | public Long querySingleResultLong(String query, Object... fields) { |
| 317 | try { |
| 318 | PreparedStatement statement = prepareStatement(query, fields); |
| 319 | ResultSet results = statement.executeQuery(); |
| 320 | if (!results.next()) { |
| 321 | return null; |
| 322 | } |
| 323 | long val = results.getLong(1); |
| 324 | results.close(); |
| 325 | statement.close(); |
| 326 | return val; |
| 327 | } catch (SQLException e) { |
| 328 | sneakyThrow(e); |
| 329 | return null; |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | /** |
| 334 | * Executes a SQL query as a prepared statement, setting its fields to the elements of the vararg passed, |
no test coverage detected