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

Method querySingleResultString

src/redempt/redlib/sql/SQLHelper.java:264–279  ·  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 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)

Source from the content-addressed store, hash-verified

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,

Callers 2

selectStringMethod · 0.80
loadMethod · 0.80

Calls 5

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

Tested by

no test coverage detected