MCPcopy Create free account
hub / github.com/boxbeam/RedLib / querySingleResultLong

Method querySingleResultLong

src/redempt/redlib/sql/SQLHelper.java:316–331  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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,

Callers 1

selectLongMethod · 0.80

Calls 5

prepareStatementMethod · 0.95
sneakyThrowMethod · 0.95
closeMethod · 0.65
nextMethod · 0.45
getLongMethod · 0.45

Tested by

no test coverage detected