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

Method queryResultList

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

Executes a SQL query as a prepared statement, setting its fields to the elements of the vararg passed, returning a list of values in the first column of each row in the results @param query The SQL query to execute @param fields A vararg of the fields to set in the prepared statement @param

(String query, Object... fields)

Source from the content-addressed store, hash-verified

340 * @return A list of the value in the first column of each row returned by the query
341 */
342 public <T> List<T> queryResultList(String query, Object... fields) {
343 List<T> list = new ArrayList<>();
344 try {
345 PreparedStatement statement = prepareStatement(query, fields);
346 ResultSet results = statement.executeQuery();
347 while (results.next()) {
348 list.add((T) results.getObject(1));
349 }
350 results.close();
351 statement.close();
352 } catch (SQLException e) {
353 sneakyThrow(e);
354 }
355 return list;
356 }
357
358 /**
359 * Executes a SQL query as a prepared statement, setting its fields to the elements of the vararg passed,

Callers

nothing calls this directly

Calls 6

prepareStatementMethod · 0.95
sneakyThrowMethod · 0.95
closeMethod · 0.65
nextMethod · 0.45
addMethod · 0.45
getObjectMethod · 0.45

Tested by

no test coverage detected