public final class Database
extends java.lang.Object
implements java.lang.AutoCloseable
Modifier and Type | Field and Description |
---|---|
static java.lang.Object |
NULL_BLOB
Sentinel object used to indicate in parameters of a query that rather than
calling
PreparedStatement.setObject(int, Object) with a null we call
PreparedStatement.setNull(int, int) with Types.CLOB . |
static java.lang.Object |
NULL_CLOB |
static java.lang.Object |
NULL_NUMBER |
Modifier and Type | Method and Description |
---|---|
<T> io.reactivex.Completable |
apply(io.reactivex.functions.Consumer<? super java.sql.Connection> consumer) |
<T> io.reactivex.Single<T> |
apply(io.reactivex.functions.Function<? super java.sql.Connection,? extends T> function) |
static java.lang.Object |
blob(byte[] bytes) |
CallableBuilder |
call(java.lang.String sql) |
static java.lang.Object |
clob(java.lang.String s) |
void |
close() |
io.reactivex.Single<java.sql.Connection> |
connection() |
io.reactivex.Flowable<java.sql.Connection> |
connections()
Returns a flowable stream of checked out Connections from the pool.
|
static Database |
from(org.davidmoten.rx.pool.Pool<java.sql.Connection> pool) |
static Database |
from(org.davidmoten.rx.pool.Pool<java.sql.Connection> pool,
io.reactivex.functions.Action closeAction) |
static Database |
from(java.lang.String url,
int maxPoolSize) |
static Database |
fromBlocking(ConnectionProvider cp) |
static Database |
fromBlocking(javax.sql.DataSource dataSource) |
io.reactivex.Single<org.davidmoten.rx.pool.Member<java.sql.Connection>> |
member()
Returns a Single of a member of the connection pool.
|
static NonBlockingConnectionPool.Builder<Database> |
nonBlocking() |
<T> SelectAutomappedBuilder<T> |
select(java.lang.Class<T> cls) |
SelectBuilder |
select(java.lang.String sql) |
static Database |
test()
Returns a new testing Apache Derby in-memory database with a connection pool
of size 3.
|
static Database |
test(int maxPoolSize) |
static java.lang.Object |
toSentinelIfNull(byte[] bytes) |
static java.lang.Object |
toSentinelIfNull(java.lang.String s) |
TransactedBuilder |
tx(Tx<?> tx) |
UpdateBuilder |
update(java.lang.String sql) |
public static final java.lang.Object NULL_CLOB
public static final java.lang.Object NULL_NUMBER
public static final java.lang.Object NULL_BLOB
PreparedStatement.setObject(int, Object)
with a null we call
PreparedStatement.setNull(int, int)
with Types.CLOB
. This is
required by many databases for setting CLOB and BLOB fields to null.public static NonBlockingConnectionPool.Builder<Database> nonBlocking()
public static Database from(@Nonnull java.lang.String url, int maxPoolSize)
public static Database from(@Nonnull org.davidmoten.rx.pool.Pool<java.sql.Connection> pool)
public static Database from(@Nonnull org.davidmoten.rx.pool.Pool<java.sql.Connection> pool, io.reactivex.functions.Action closeAction)
public static Database fromBlocking(@Nonnull ConnectionProvider cp)
public static Database fromBlocking(@Nonnull javax.sql.DataSource dataSource)
public static Database test(int maxPoolSize)
public static Database test()
public io.reactivex.Single<java.sql.Connection> connection()
public io.reactivex.Flowable<java.sql.Connection> connections()
Returns a flowable stream of checked out Connections from the pool. It's
preferrable to use the connection()
method and subscribe to a
MemberSingle instead because the sometimes surprising request patterns of
Flowable operators may mean that more Connections are checked out from the
pool than are needed. For instance if you use
Flowable<Connection> cons = Database.connection().repeat()
then you will checkout more (1 more) Connection with repeat
than you
requested because repeat
subscribes one more time than dictated by
the requests (buffers).
close()
on a connection it is returned to the poolpublic void close()
close
in interface java.lang.AutoCloseable
public CallableBuilder call(@Nonnull java.lang.String sql)
public <T> SelectAutomappedBuilder<T> select(@Nonnull java.lang.Class<T> cls)
public SelectBuilder select(@Nonnull java.lang.String sql)
public UpdateBuilder update(@Nonnull java.lang.String sql)
public TransactedBuilder tx(@Nonnull Tx<?> tx)
public static java.lang.Object toSentinelIfNull(@Nullable java.lang.String s)
public static java.lang.Object toSentinelIfNull(@Nullable byte[] bytes)
public static java.lang.Object clob(@Nullable java.lang.String s)
public static java.lang.Object blob(@Nullable byte[] bytes)
public io.reactivex.Single<org.davidmoten.rx.pool.Member<java.sql.Connection>> member()
member.checkin()
to return the
connection to the pool.public <T> io.reactivex.Single<T> apply(io.reactivex.functions.Function<? super java.sql.Connection,? extends T> function)
public <T> io.reactivex.Completable apply(io.reactivex.functions.Consumer<? super java.sql.Connection> consumer)
Copyright © 2016–2020. All rights reserved.