public class FiberDataSource extends Object implements DataSource
A JDBC DataSource
that creates connections that can be used in Quasar fibers. This class simply wraps any JDBC data source, and executes any JDBC operations in a separate ExecutorService
.
Modifier | Constructor and Description |
---|---|
protected |
FiberDataSource(DataSource ds,
ExecutorService exec) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
FiberConnection |
getConnection() |
FiberConnection |
getConnection(String username,
String password) |
int |
getLoginTimeout() |
PrintWriter |
getLogWriter() |
Logger |
getParentLogger() |
int |
hashCode() |
boolean |
isWrapperFor(Class<?> iface) |
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(PrintWriter out) |
String |
toString() |
<T> T |
unwrap(Class<T> iface) |
static DataSource |
wrap(DataSource ds)
Wraps a JDBC
DataSource with fixed 10 threads pool executor. |
static DataSource |
wrap(DataSource ds,
ExecutorService executor)
Wraps a JDBC
DataSource . |
static DataSource |
wrap(DataSource ds,
int numThreads)
Wraps a JDBC
DataSource . |
protected FiberDataSource(DataSource ds, ExecutorService exec)
public static DataSource wrap(DataSource ds, ExecutorService executor)
Wraps a JDBC DataSource
.
ds
- The DataSource
to wrap.executor
- The ExecutorService
to use to actually execute JDBC operations.public static DataSource wrap(DataSource ds, int numThreads)
Wraps a JDBC DataSource
.
ds
- The DataSource
to wrap.numThreads
- The number of threads to create in the thread pool that will be used to execute JDBC operations.public static DataSource wrap(DataSource ds)
Wraps a JDBC DataSource
with fixed 10 threads pool executor.
ds
- The DataSource
to wrap.@Suspendable public FiberConnection getConnection() throws SQLException
getConnection
in interface DataSource
SQLException
@Suspendable public FiberConnection getConnection(String username, String password) throws SQLException
getConnection
in interface DataSource
SQLException
@Suspendable public PrintWriter getLogWriter() throws SQLException
getLogWriter
in interface CommonDataSource
SQLException
@Suspendable public void setLogWriter(PrintWriter out) throws SQLException
setLogWriter
in interface CommonDataSource
SQLException
@Suspendable public void setLoginTimeout(int seconds) throws SQLException
setLoginTimeout
in interface CommonDataSource
SQLException
@Suspendable public int getLoginTimeout() throws SQLException
getLoginTimeout
in interface CommonDataSource
SQLException
public Logger getParentLogger() throws SQLFeatureNotSupportedException
getParentLogger
in interface CommonDataSource
SQLFeatureNotSupportedException
public <T> T unwrap(Class<T> iface) throws SQLException
unwrap
in interface Wrapper
SQLException
public boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor
in interface Wrapper
SQLException