public final class Database extends Object implements AutoCloseable
Modifier and Type | Field and Description |
---|---|
static 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 Object |
NULL_CLOB |
static Object |
NULL_NUMBER |
Modifier and Type | Method and Description |
---|---|
<T> io.reactivex.rxjava3.core.Completable |
apply(io.reactivex.rxjava3.functions.Consumer<? super Connection> consumer) |
<T> io.reactivex.rxjava3.core.Single<T> |
apply(io.reactivex.rxjava3.functions.Function<? super Connection,? extends T> function) |
static Object |
blob(byte[] bytes) |
CallableBuilder |
call(String sql) |
static Object |
clob(String s) |
void |
close() |
io.reactivex.rxjava3.core.Single<Connection> |
connection() |
io.reactivex.rxjava3.core.Flowable<Connection> |
connections()
Returns a flowable stream of checked out Connections from the pool.
|
static Database |
from(org.davidmoten.rxjava3.pool.Pool<Connection> pool) |
static Database |
from(org.davidmoten.rxjava3.pool.Pool<Connection> pool,
io.reactivex.rxjava3.functions.Action closeAction) |
static Database |
from(String url,
int maxPoolSize) |
static Database |
fromBlocking(ConnectionProvider cp) |
static Database |
fromBlocking(DataSource dataSource) |
io.reactivex.rxjava3.core.Single<org.davidmoten.rxjava3.pool.Member<Connection>> |
member()
Returns a Single of a member of the connection pool.
|
static NonBlockingConnectionPool.Builder<Database> |
nonBlocking() |
<T> SelectAutomappedBuilder<T> |
select(Class<T> cls) |
SelectBuilder |
select(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 Object |
toSentinelIfNull(byte[] bytes) |
static Object |
toSentinelIfNull(String s) |
TransactedBuilder |
tx(Tx<?> tx) |
UpdateBuilder |
update(String sql) |
public static final Object NULL_CLOB
public static final Object NULL_NUMBER
public static final 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 org.davidmoten.rxjava3.pool.Pool<Connection> pool)
public static Database from(@Nonnull org.davidmoten.rxjava3.pool.Pool<Connection> pool, io.reactivex.rxjava3.functions.Action closeAction)
public static Database fromBlocking(@Nonnull ConnectionProvider cp)
public static Database fromBlocking(@Nonnull DataSource dataSource)
public static Database test(int maxPoolSize)
public static Database test()
public io.reactivex.rxjava3.core.Single<Connection> connection()
public io.reactivex.rxjava3.core.Flowable<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 AutoCloseable
public CallableBuilder call(@Nonnull String sql)
public <T> SelectAutomappedBuilder<T> select(@Nonnull Class<T> cls)
public SelectBuilder select(@Nonnull String sql)
public UpdateBuilder update(@Nonnull String sql)
public TransactedBuilder tx(@Nonnull Tx<?> tx)
public io.reactivex.rxjava3.core.Single<org.davidmoten.rxjava3.pool.Member<Connection>> member()
member.checkin()
to return the
connection to the pool.public <T> io.reactivex.rxjava3.core.Single<T> apply(io.reactivex.rxjava3.functions.Function<? super Connection,? extends T> function)
public <T> io.reactivex.rxjava3.core.Completable apply(io.reactivex.rxjava3.functions.Consumer<? super Connection> consumer)
Copyright © 2022–2023. All rights reserved.