本文整理汇总了Java中org.jdbi.v3.core.statement.StatementContext类的典型用法代码示例。如果您正苦于以下问题:Java StatementContext类的具体用法?Java StatementContext怎么用?Java StatementContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StatementContext类属于org.jdbi.v3.core.statement包,在下文中一共展示了StatementContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterExecution
import org.jdbi.v3.core.statement.StatementContext; //导入依赖的package包/类
@Override
public void afterExecution(PreparedStatement stmt, StatementContext ctx) throws SQLException {
Optional<Argument> bindingVal = ctx.getBinding().findForName(binding, ctx);
if (! bindingVal.isPresent()) {
LoggerFactory.getLogger(getClass()).warn("Missing binding '{}'. Cannot update counter", binding);
return;
}
try (PreparedStatement sql = ctx.getConnection().prepareStatement(query)) {
sql.setString(1, String.valueOf(bindingVal.get()));
sql.execute();
LoggerFactory.getLogger(getClass()).debug("Executed SQL: {}", query);
} catch (SQLException e) {
throw e;
}
}
示例2: build
import org.jdbi.v3.core.statement.StatementContext; //导入依赖的package包/类
@Override
protected Argument build(double[] value, ConfigRegistry config) {
return new Argument() {
@Override
public void apply(int position, PreparedStatement statement, StatementContext ctx) throws SQLException {
if (value != null) {
Object[] wrappedValue = new Object[value.length];
for (int i = 0; i < value.length; i++) {
wrappedValue[i] = value[i];
}
statement.setArray(position, ctx.getConnection().createArrayOf("NUMERIC", wrappedValue));
} else {
statement.setNull(position, Types.ARRAY);
}
}
};
}
示例3: map
import org.jdbi.v3.core.statement.StatementContext; //导入依赖的package包/类
@Override
public Person map(ResultSet resultSet, StatementContext statementContext) throws SQLException {
Person person = new Person(resultSet.getString("firstName"), resultSet.getString("lastName"), resultSet.getString("email"));
person.setId(resultSet.getInt("id"));
person.setCreated(resultSet.getTimestamp("created"));
person.setModified(resultSet.getTimestamp("modified"));
return person;
}
示例4: map
import org.jdbi.v3.core.statement.StatementContext; //导入依赖的package包/类
@Override
public Player map(ResultSet r, StatementContext ctx) throws SQLException {
int height = r.getInt("height");
int weight = r.getInt("weight");
return new Player(Optional.of(r.getLong("id")), r.getString("first_name"), r.getString("last_name"),
r.getTimestamp("birth_date"),
height != 0 ? Optional.of(height) : Optional.empty(),
weight != 0 ? Optional.of(weight) : Optional.empty());
}
示例5: map
import org.jdbi.v3.core.statement.StatementContext; //导入依赖的package包/类
@Override
public City map(ResultSet r, StatementContext statementContext) throws SQLException {
Object[] locationArray = (Object[]) r.getArray("location").getArray();
double[] location = new double[locationArray.length];
for (int i = 0; i < locationArray.length; i++) {
location[i] = (double) locationArray[i];
}
return new City(r.getLong("id"), r.getString("name"), r.getString("region_code"),
r.getString("country_code"), location);
}
示例6: map
import org.jdbi.v3.core.statement.StatementContext; //导入依赖的package包/类
@Override
public ImmutableDebut map(ResultSet r, StatementContext ctx) throws SQLException {
return ImmutableDebut.builder()
.code(r.getString("debut_code"))
.name(r.getString("debut_name"))
.build();
}
示例7: map
import org.jdbi.v3.core.statement.StatementContext; //导入依赖的package包/类
@Override
public ImmutableChessPlayer map(ResultSet r, StatementContext ctx) throws SQLException {
return ImmutableChessPlayer.builder()
.firstName(r.getString("player_first_name"))
.lastName(r.getString("player_last_name"))
.rank(Rank.valueOf(r.getString("player_rank").toUpperCase()))
.build();
}
示例8: map
import org.jdbi.v3.core.statement.StatementContext; //导入依赖的package包/类
@Override
public ImmutableChessGame map(ResultSet r, StatementContext ctx) throws SQLException {
return ImmutableChessGame.builder()
.white(chessPlayerMapper.map("white_", r))
.black(chessPlayerMapper.map("black_", r))
.debut(debutMapper.map(r, ctx))
.result(Result.valueOf(r.getString("result_name").toUpperCase()))
.build();
}
示例9: map
import org.jdbi.v3.core.statement.StatementContext; //导入依赖的package包/类
@Override public Pet map(final ResultSet rs, final StatementContext ctx) throws SQLException {
return new Pet(rs.getLong("id"), rs.getString("name"));
}
示例10: map
import org.jdbi.v3.core.statement.StatementContext; //导入依赖的package包/类
@Override
public Money map(ResultSet r, int columnNumber, StatementContext ctx) throws SQLException {
return Money.of(USD, r.getBigDecimal(columnNumber));
}
示例11: map
import org.jdbi.v3.core.statement.StatementContext; //导入依赖的package包/类
@Override
public Contact map(ResultSet r, StatementContext ctx) throws SQLException {
int id = r.getInt("id");
String name = r.getString("name");
return new Contact(id, name);
}
示例12: map
import org.jdbi.v3.core.statement.StatementContext; //导入依赖的package包/类
@Override
public Player map(ResultSet r, StatementContext ctx) throws SQLException {
return new Player(r.getLong("id"), r.getString("first_name"), r.getString("last_name"),
r.getTimestamp("birth_date"), r.getInt("height"), r.getInt("weight"));
}
示例13: map
import org.jdbi.v3.core.statement.StatementContext; //导入依赖的package包/类
@Override
public Movie map(ResultSet r, StatementContext statementContext) throws SQLException {
return new Movie(r.getLong("id"), r.getString("name"), r.getInt("year"), r.getString("director"));
}
示例14: map
import org.jdbi.v3.core.statement.StatementContext; //导入依赖的package包/类
@Override
public Actor map(ResultSet r, StatementContext ctx) throws SQLException {
return new Actor(r.getLong("id"), r.getString("first_name"), r.getString("last_name"),
Gender.valueOf(r.getString("gender").toUpperCase()), countryMapper.map(r, ctx));
}
示例15: map
import org.jdbi.v3.core.statement.StatementContext; //导入依赖的package包/类
@Override
public Country map(ResultSet r, StatementContext statementContext) throws SQLException {
return new Country(r.getString("alpha2_code"), r.getString("name"));
}