当前位置: 首页>>代码示例>>Java>>正文


Java StatementContext类代码示例

本文整理汇总了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;
    }
}
 
开发者ID:zikani03,项目名称:jdbi-utils,代码行数:18,代码来源:CounterCustomizer.java

示例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);
            }
        }
    };
}
 
开发者ID:arteam,项目名称:jdit-examples,代码行数:18,代码来源:DoubleArrayArgumentFactory.java

示例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;
}
 
开发者ID:zikani03,项目名称:jdbi-utils,代码行数:9,代码来源:PersonDAO.java

示例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());
}
 
开发者ID:arteam,项目名称:jdit,代码行数:10,代码来源:AdvancedPlayerSqlObject.java

示例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);
}
 
开发者ID:arteam,项目名称:jdit-examples,代码行数:11,代码来源:CityMapper.java

示例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();
}
 
开发者ID:arteam,项目名称:jdit-examples,代码行数:8,代码来源:DebutMapper.java

示例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();
}
 
开发者ID:arteam,项目名称:jdit-examples,代码行数:9,代码来源:ChessPlayerMapper.java

示例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();
}
 
开发者ID:arteam,项目名称:jdit-examples,代码行数:10,代码来源:ChessGameMapper.java

示例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"));
}
 
开发者ID:jooby-project,项目名称:jdbi-starter,代码行数:4,代码来源:Pet.java

示例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));
}
 
开发者ID:qualidafial,项目名称:jdbi-examples,代码行数:5,代码来源:Example04ColumnMapper.java

示例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);
}
 
开发者ID:qualidafial,项目名称:jdbi-examples,代码行数:7,代码来源:Example02RowMapper.java

示例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"));

}
 
开发者ID:arteam,项目名称:jdit-examples,代码行数:7,代码来源:PlayerMapper.java

示例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"));
}
 
开发者ID:arteam,项目名称:jdit-examples,代码行数:5,代码来源:Movie.java

示例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));
}
 
开发者ID:arteam,项目名称:jdit-examples,代码行数:6,代码来源:Actor.java

示例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"));
}
 
开发者ID:arteam,项目名称:jdit-examples,代码行数:5,代码来源:Country.java


注:本文中的org.jdbi.v3.core.statement.StatementContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。