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

Method querySingleResultBytes

src/redempt/redlib/sql/SQLHelper.java:289–304  ·  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 Bytes. @param query The SQL query to execute @param fields A vararg of the fields to set in the prepared statement @re

(String query, Object... fields)

Source from the content-addressed store, hash-verified

287 * @return The bytes in the first column of the first row of the returned results, or null if none is present
288 */
289 public byte[] querySingleResultBytes(String query, Object... fields) {
290 try {
291 PreparedStatement statement = prepareStatement(query, fields);
292 ResultSet results = statement.executeQuery();
293 if (!results.next()) {
294 return null;
295 }
296 byte[] val = results.getBytes(1);
297 results.close();
298 statement.close();
299 return val;
300 } catch (SQLException e) {
301 sneakyThrow(e);
302 return null;
303 }
304 }
305
306 /**
307 * Executes a SQL query as a prepared statement, setting its fields to the elements of the vararg passed,

Callers

nothing calls this directly

Calls 5

prepareStatementMethod · 0.95
sneakyThrowMethod · 0.95
getBytesMethod · 0.80
closeMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected