本文整理汇总了Java中ru.otus.executor.TExecutor类的典型用法代码示例。如果您正苦于以下问题:Java TExecutor类的具体用法?Java TExecutor怎么用?Java TExecutor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TExecutor类属于ru.otus.executor包,在下文中一共展示了TExecutor类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import ru.otus.executor.TExecutor; //导入依赖的package包/类
public UsersDataSet get(long id) throws SQLException {
TExecutor exec = new TExecutor(connection);
return exec.execQuery("select * from users where id=" + id, result -> {
result.next();
return new UsersDataSet(result.getLong(1), result.getString(2));
});
}
示例2: getAllNames
import ru.otus.executor.TExecutor; //导入依赖的package包/类
@Override
public List<String> getAllNames() throws SQLException {
TExecutor executor = new TExecutor(getConnection());
return executor.execQuery("select name from user", result -> {
List<String> names = new ArrayList<>();
while (!result.isLast()) {
result.next();
names.add(result.getString("name"));
}
return names;
});
}
示例3: getUserName
import ru.otus.executor.TExecutor; //导入依赖的package包/类
@Override
public String getUserName(int id) throws SQLException {
TExecutor execT = new TExecutor(getConnection());
return execT.execQuery(String.format(SELECT_USER, id), result -> {
result.next();
return result.getString("name");
});
}