-
- All Superinterfaces:
java.lang.AutoCloseable
public interface DataSource extends java.lang.AutoCloseable
Uses the builder pattern to get aSession
. AgetSession()
method is provided as a convenience. Implementations must be thread safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
DataSource.Builder
Instances of this type are used to buildDataSource
s.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Session.Builder
builder()
Returns aSession
builder.void
close()
default Session
getSession()
default Session
getSession(java.util.function.Consumer<java.lang.Throwable> handler)
default java.util.List<java.lang.String>
supportedTranslateSqlFormats()
Return a list of the source formats accepted by thetranslateSql(java.lang.String,java.lang.String)
method.default java.lang.String
translateSql(java.lang.String format, java.lang.String source)
Translates a SQL string from the format specified by the format argument to a format that can be used to createOperation
s for theSession
s provided by thisDataSource
.
-
-
-
Method Detail
-
builder
Session.Builder builder()
Returns aSession
builder. By default that builder will returnSession
s with theSessionProperty
s specified when creating this DataSource. Default and unspecifiedSessionProperty
s can be set with the returned builder.- Returns:
- a new
Session
builder. Notnull
. - Throws:
java.lang.IllegalStateException
- if thisDataSource
is closed
-
getSession
default Session getSession()
Returns aSession
that has a submitted attachOperation
. Convenience method for use with try with resources.- Returns:
- a
Session
- Throws:
java.lang.IllegalStateException
- if thisDataSource
is closed
-
getSession
default Session getSession(java.util.function.Consumer<java.lang.Throwable> handler)
Returns aSession
that has a submitted attachOperation
with an error handler. Convenience method for use with try with resources. The error handle handles errors in the attachOperation
.- Parameters:
handler
- for errors in the attachOperation
- Returns:
- a
Session
- Throws:
java.lang.IllegalStateException
- if thisDataSource
is closed
-
translateSql
default java.lang.String translateSql(java.lang.String format, java.lang.String source) throws SqlException
Translates a SQL string from the format specified by the format argument to a format that can be used to createOperation
s for theSession
s provided by thisDataSource
. ISSUE: Just an idea- Parameters:
format
- notnull
source
- SQL in the format specified byformat
. Notnull
.- Returns:
- SQL in the format supported by this
DataSource
. Notnull
. - Throws:
java.lang.IllegalArgumentException
- if theformat
is not supported or if theDataSource
cannot translate the SQLjava.lang.IllegalStateException
- if thisDataSource
is closedSqlException
-
supportedTranslateSqlFormats
default java.util.List<java.lang.String> supportedTranslateSqlFormats()
Return a list of the source formats accepted by thetranslateSql(java.lang.String,java.lang.String)
method. ISSUE: Just an idea- Returns:
- an array of Strings each of which identifies a supported format
- Throws:
java.lang.IllegalStateException
- if thisDataSource
is closed
-
close
void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
-
-