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 String. @param query The SQL query to execute @param fields A vararg of the fields to set in the prepared statement @r
(String query, Object... fields)
| 262 | * column can be parsed into one. |
| 263 | */ |
| 264 | public String querySingleResultString(String query, Object... fields) { |
| 265 | try { |
| 266 | PreparedStatement statement = prepareStatement(query, fields); |
| 267 | ResultSet results = statement.executeQuery(); |
| 268 | if (!results.next()) { |
| 269 | return null; |
| 270 | } |
| 271 | String val = results.getString(1); |
| 272 | results.close(); |
| 273 | statement.close(); |
| 274 | return val; |
| 275 | } catch (SQLException e) { |
| 276 | sneakyThrow(e); |
| 277 | return null; |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | /** |
| 282 | * Executes a SQL query as a prepared statement, setting its fields to the elements of the vararg passed, |
no test coverage detected