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

Method queryResultStringList

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

Executes a SQL query as a prepared statement, setting its fields to the elements of the vararg passed, returning a String 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 @retur

(String query, Object... fields)

Source from the content-addressed store, hash-verified

366 * column can be parsed into one.
367 */
368 public List<String> queryResultStringList(String query, Object... fields) {
369 List<String> list = new ArrayList<>();
370 try {
371 PreparedStatement statement = prepareStatement(query, fields);
372 ResultSet results = statement.executeQuery();
373 while (results.next()) {
374 list.add(results.getString(1));
375 }
376 results.close();
377 statement.close();
378 } catch (SQLException e) {
379 sneakyThrow(e);
380 }
381 return list;
382 }
383
384 /**
385 * 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
getStringMethod · 0.65
closeMethod · 0.65
nextMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected