throw new ResultSetException("Unable to obtain metadata from result set", e, ctx); throw new ResultSetException("Unable to access specific metadata from " + "result set metadata", e, ctx);
@Override public SingularityRequestHistory map(int index, ResultSet r, StatementContext ctx) throws SQLException { try { return new SingularityRequestHistory(r.getTimestamp("createdAt").getTime(), Optional.fromNullable(r.getString(userColumn)), RequestHistoryType.valueOf(r.getString("requestState")), singularityRequestTranscoder.fromBytes(r.getBytes("request")), Optional.fromNullable(r.getString("message"))); } catch (SingularityTranscoderException e) { throw new ResultSetException("Could not deserialize database result", e, ctx); } } }
@Override public SingularityTaskIdHistory map(int index, ResultSet r, StatementContext ctx) throws SQLException { try { final SingularityTaskId taskId = singularityTaskIdTranscoder.fromString(r.getString("taskId")); final String lastTaskStatus = r.getString("lastTaskStatus"); Optional<ExtendedTaskState> lastTaskState = Optional.absent(); if (lastTaskStatus != null) { try { lastTaskState = Optional.of(ExtendedTaskState.valueOf(lastTaskStatus)); } catch (IllegalArgumentException e) { LOG.warn("Found invalid taskState {} in DB for task {}", lastTaskState, taskId, e); } } return new SingularityTaskIdHistory(taskId, r.getTimestamp("updatedAt").getTime(), lastTaskState, Optional.fromNullable(r.getString("runId"))); } catch (SingularityTranscoderException e) { throw new ResultSetException("Could not deserialize database result", e, ctx); } } }
private boolean safeNext() { try { return results.next(); } catch (SQLException e) { throw new ResultSetException("Unable to advance result set", e, context); } } }
private boolean safeNext() { try { return results.next(); } catch (SQLException e) { throw new ResultSetException("Unable to advance result set", e, context); } } }
/** * Returns a iterator over all generated keys. * * @return The key iterator */ @Override public ResultIterator<Type> iterator() { try { return new ResultSetResultIterator<Type>(mapper, jdbiStatement, stmt, context); } catch (SQLException e) { throw new ResultSetException("Exception thrown while attempting to traverse the result set", e, context); } }
@Override public void afterExecution(PreparedStatement stmt, StatementContext ctx) throws SQLException { ResultSet rs; try { rs = (ResultSet) this.getReturnResultSet.invoke(this.stmt); } catch (Exception e) { throw new ResultSetException("Unable to retrieve return result set", e, ctx); } this.results = new ArrayList<ResultType>(); try { int i = 0; while (rs.next()) { results.add(mapper.map(i++, rs, context)); } } catch (SQLException e) { throw new ResultSetException("Unable to retrieve results from returned result set", e, ctx); } }
/** * Returns a iterator over all generated keys. * * @return The key iterator */ public ResultIterator<Type> iterator() { try { return new ResultSetResultIterator<Type>(mapper, jdbiStatement, stmt, context); } catch (SQLException e) { throw new ResultSetException("Exception thrown while attempting to traverse the result set", e, context); } }
@Override public void afterExecution(PreparedStatement stmt, StatementContext ctx) throws SQLException { ResultSet rs; try { rs = (ResultSet) this.getReturnResultSet.invoke(this.stmt); } catch (Exception e) { throw new ResultSetException("Unable to retrieve return result set", e, ctx); } this.results = new ArrayList<ResultType>(); try { int i = 0; while (rs.next()) { results.add(mapper.map(i++, rs, context)); } } catch (SQLException e) { throw new ResultSetException("Unable to retrieve results from returned result set", e, ctx); } }
@Override public SingularityRequestHistory map(int index, ResultSet r, StatementContext ctx) throws SQLException { try { return new SingularityRequestHistory(r.getTimestamp("createdAt").getTime(), Optional.fromNullable(r.getString(userColumn)), RequestHistoryType.valueOf(r.getString("requestState")), singularityRequestTranscoder.fromBytes(r.getBytes("request")), Optional.fromNullable(r.getString("message"))); } catch (SingularityTranscoderException e) { throw new ResultSetException("Could not deserialize database result", e, ctx); } } }
public Map<String, Object> map(int index, ResultSet r, StatementContext ctx) { Map<String, Object> row = new DefaultResultMap(); ResultSetMetaData m; try { m = r.getMetaData(); } catch (SQLException e) { throw new ResultSetException("Unable to obtain metadata from result set", e, ctx); } try { for (int i = 1; i <= m.getColumnCount(); i ++) { String key = m.getColumnName(i); Object value = r.getObject(i); row.put(key, value); } } catch (SQLException e) { throw new ResultSetException("Unable to access specific metadata from " + "result set metadata", e, ctx); } return row; }
public Map<String, Object> map(int index, ResultSet r, StatementContext ctx) { Map<String, Object> row = new DefaultResultMap(); ResultSetMetaData m; try { m = r.getMetaData(); } catch (SQLException e) { throw new ResultSetException("Unable to obtain metadata from result set", e, ctx); } try { for (int i = 1; i <= m.getColumnCount(); i ++) { String key = m.getColumnName(i); String alias = m.getColumnLabel(i); Object value = r.getObject(i); row.put(alias != null ? alias : key, value); } } catch (SQLException e) { throw new ResultSetException("Unable to access specific metadata from " + "result set metadata", e, ctx); } return row; }
@Override public Map<String, Object> map(int index, ResultSet r, StatementContext ctx) { Map<String, Object> row = new DefaultResultMap(); ResultSetMetaData m; try { m = r.getMetaData(); } catch (SQLException e) { throw new ResultSetException("Unable to obtain metadata from result set", e, ctx); } try { for (int i = 1; i <= m.getColumnCount(); i ++) { String key = m.getColumnName(i); String alias = m.getColumnLabel(i); Object value = r.getObject(i); row.put(alias != null ? alias : key, value); } } catch (SQLException e) { throw new ResultSetException("Unable to access specific metadata from " + "result set metadata", e, ctx); } return row; }
@Override public SingularityTaskIdHistory map(int index, ResultSet r, StatementContext ctx) throws SQLException { try { final SingularityTaskId taskId = singularityTaskIdTranscoder.fromString(r.getString("taskId")); final String lastTaskStatus = r.getString("lastTaskStatus"); Optional<ExtendedTaskState> lastTaskState = Optional.absent(); if (lastTaskStatus != null) { try { lastTaskState = Optional.of(ExtendedTaskState.valueOf(lastTaskStatus)); } catch (IllegalArgumentException e) { LOG.warn("Found invalid taskState {} in DB for task {}", lastTaskState, taskId, e); } } return new SingularityTaskIdHistory(taskId, r.getTimestamp("updatedAt").getTime(), lastTaskState, Optional.fromNullable(r.getString("runId"))); } catch (SingularityTranscoderException e) { throw new ResultSetException("Could not deserialize database result", e, ctx); } } }
@Override public List<Type> list(int maxRows) { try { int idx = 0; List<Type> resultList = new ArrayList<Type>(); if (results != null && ++idx <= maxRows && !results.isClosed()) { int index = 0; while (results.next()) { resultList.add(mapper.map(index++, results, context)); } } return resultList; } catch (SQLException e) { throw new ResultSetException("Exception thrown while attempting to traverse the result set", e, context); } finally { jdbiStatement.cleanup(); } }
/** * Returns the first generated key. * * @return The key or null if no keys were returned */ public Type first() { try { if (results != null && results.next()) { return mapper.map(0, results, context); } else { // no result matches return null; } } catch (SQLException e) { throw new ResultSetException("Exception thrown while attempting to traverse the result set", e, context); } finally { jdbiStatement.cleanup(); } }
/** * Returns the first generated key. * * @return The key or null if no keys were returned */ @Override public Type first() { try { if (results != null && results.next()) { return mapper.map(0, results, context); } else { // no result matches return null; } } catch (SQLException e) { throw new ResultSetException("Exception thrown while attempting to traverse the result set", e, context); } finally { jdbiStatement.cleanup(); } }
public List<Type> list(int maxRows) { try { int idx = 0; List<Type> resultList = new ArrayList<Type>(); if (results != null && ++idx <= maxRows && !results.isClosed()) { int index = 0; while (results.next()) { resultList.add(mapper.map(index++, results, context)); } } return resultList; } catch (SQLException e) { throw new ResultSetException("Exception thrown while attempting to traverse the result set", e, context); } finally { jdbiStatement.cleanup(); } }
throw new ResultSetException("Unable to obtain metadata from result set", e, ctx); throw new ResultSetException("Unable to access specific metadata from " + "result set metadata", e, ctx);
throw new ResultSetException("Exception thrown while attempting to traverse the result set", e, context);