本文整理汇总了Java中org.davidmoten.rx.jdbc.Database类的典型用法代码示例。如果您正苦于以下问题:Java Database类的具体用法?Java Database怎么用?Java Database使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Database类属于org.davidmoten.rx.jdbc包,在下文中一共展示了Database类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryMetadata
import org.davidmoten.rx.jdbc.Database; //导入依赖的package包/类
private static synchronized Single<HashMap<String, String>> queryMetadata(Database dataSource) {
final URL url = Resources.getResource("metadata_key_value.sql");
String query;
try {
query = Resources.toString(url, Charsets.UTF_8);
} catch (final IOException ex) {
return Single.error(ex);
}
return dataSource.select(query).get(new ResultSetMapper<HashMap<String, String>>() {
@Override
public HashMap<String, String> apply(@Nonnull ResultSet rs) throws SQLException {
final HashMap<String, String> metadata = new LinkedHashMap<>();
while (rs.getRow() != 0) {
metadata.put(rs.getString("name"), rs.getString("value"));
rs.next();
}
return metadata;
}
}).singleOrError();
}
示例2: StorageImpl
import org.davidmoten.rx.jdbc.Database; //导入依赖的package包/类
private StorageImpl(File file) {
Database datasource = null;
boolean isError = true;
try {
datasource = Database.fromBlocking(connectionProvider("jdbc:sqlite:"
+ file.getAbsolutePath()));
isError = false;
} catch (final Exception ex) {
LOG.error("problem establishing a connection", ex);
}
this.dataSource = datasource;
this.isError = isError;
}
示例3: createDerby
import org.davidmoten.rx.jdbc.Database; //导入依赖的package包/类
private static Database createDerby(int maxSize, boolean withStoredProcs) {
return Database.from(Pools.nonBlocking() //
.connectionProvider(connectionProviderDerby(nextUrlDerby(), withStoredProcs)) //
.maxPoolSize(maxSize) //
.scheduler(Schedulers.from(Executors.newFixedThreadPool(maxSize))) //
.build());
}
示例4: create
import org.davidmoten.rx.jdbc.Database; //导入依赖的package包/类
public static Database create(int maxSize, boolean big, Scheduler scheduler) {
NonBlockingConnectionPool pool = Pools.nonBlocking() //
.connectionProvider(connectionProvider(nextUrl(), big)) //
.maxPoolSize(maxSize) //
.scheduler(scheduler) //
.build();
return Database.from(pool, () -> {
pool.close();
scheduler.shutdown();
});
}
示例5: RxJava2PostRepository
import org.davidmoten.rx.jdbc.Database; //导入依赖的package包/类
RxJava2PostRepository(Database db) {
this.db = db;
}
示例6: db
import org.davidmoten.rx.jdbc.Database; //导入依赖的package包/类
@Bean
public Database db(DataSource ds){
return Database.fromBlocking(ds);
}
示例7: createBlocking
import org.davidmoten.rx.jdbc.Database; //导入依赖的package包/类
public static Database createBlocking() {
return Database.fromBlocking(connectionProvider());
}
示例8: createDerbyWithStoredProcs
import org.davidmoten.rx.jdbc.Database; //导入依赖的package包/类
public static Database createDerbyWithStoredProcs(int maxSize) {
return createDerby(maxSize, true);
}