Class EmbeddedRelationalConnection
java.lang.Object
com.apple.foundationdb.relational.recordlayer.EmbeddedRelationalConnection
- All Implemented Interfaces:
com.apple.foundationdb.relational.api.RelationalConnection
,AutoCloseable
,Connection
,Wrapper
@API(EXPERIMENTAL)
public class EmbeddedRelationalConnection
extends Object
implements com.apple.foundationdb.relational.api.RelationalConnection
Implementation of
RelationalConnection
for connecting to a database in Relational when running as an embedded library.
It can itself function in 2 modes:
- Default: The transaction is not supplied to the connection. Its start and end is guided by the JDBC
specification given the state of
autoCommit
- With External transaction: In this scenario, an already opened
Transaction
is supplied to the connection to be used to execute all statements and procedure. For consumer perspective, this is equivalent toautoCommit
being set totrue
since theConnection.commit()
andConnection.rollback()
wont be applicable. However, all statements run within the external transaction. For internal usage, the consumer should checkcanCommit()
to see if they are allowed to manage a transaction.
-
Field Summary
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
-
Constructor Summary
ConstructorsConstructorDescriptionEmbeddedRelationalConnection
(AbstractDatabase frl, StoreCatalog backingCatalog, Transaction transaction, com.apple.foundationdb.relational.api.Options options) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
commit()
createArrayOf
(String typeName, Object[] elements) com.apple.foundationdb.relational.api.fluentsql.expression.ExpressionFactory
void
com.apple.foundationdb.relational.api.RelationalStatement
com.apple.foundationdb.relational.api.fluentsql.statement.StatementBuilderFactory
createStruct
(String typeName, Object[] attributes) boolean
com.apple.foundationdb.relational.api.RelationalDatabaseMetaData
com.apple.foundationdb.relational.api.Options
getPath()
com.apple.foundationdb.relational.api.metadata.SchemaTemplate
Returns theTransaction
object if there is one active.int
boolean
isClosed()
com.apple.foundationdb.relational.api.RelationalPreparedStatement
prepareStatement
(String sql) void
rollback()
void
setAutoCommit
(boolean autoCommit) void
void
setReadOnly
(boolean readOnly) void
void
setTransactionIsolation
(int level) <T> T
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.sql.Connection
beginRequest, endRequest, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid
Methods inherited from interface com.apple.foundationdb.relational.api.RelationalConnection
abort, clearWarnings, createBlob, createClob, createNClob, createSQLXML, createStatement, createStatement, getCatalog, getClientInfo, getClientInfo, getHoldability, getNetworkTimeout, getTypeMap, isReadOnly, isValid, isWrapperFor, nativeSQL, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, setCatalog, setClientInfo, setClientInfo, setHoldability, setNetworkTimeout, setSavepoint, setSavepoint, setTypeMap
-
Constructor Details
-
EmbeddedRelationalConnection
public EmbeddedRelationalConnection(@Nonnull AbstractDatabase frl, @Nonnull StoreCatalog backingCatalog, @Nullable Transaction transaction, @Nonnull com.apple.foundationdb.relational.api.Options options) throws com.apple.foundationdb.relational.api.exceptions.InternalErrorException - Throws:
com.apple.foundationdb.relational.api.exceptions.InternalErrorException
-
-
Method Details
-
createStatement
public com.apple.foundationdb.relational.api.RelationalStatement createStatement() throws SQLException- Specified by:
createStatement
in interfaceConnection
- Specified by:
createStatement
in interfacecom.apple.foundationdb.relational.api.RelationalConnection
- Throws:
SQLException
-
prepareStatement
public com.apple.foundationdb.relational.api.RelationalPreparedStatement prepareStatement(String sql) throws SQLException - Specified by:
prepareStatement
in interfaceConnection
- Specified by:
prepareStatement
in interfacecom.apple.foundationdb.relational.api.RelationalConnection
- Throws:
SQLException
-
setReadOnly
- Specified by:
setReadOnly
in interfaceConnection
- Specified by:
setReadOnly
in interfacecom.apple.foundationdb.relational.api.RelationalConnection
- Throws:
SQLException
-
setAutoCommit
- Specified by:
setAutoCommit
in interfaceConnection
- Throws:
SQLException
-
getAutoCommit
- Specified by:
getAutoCommit
in interfaceConnection
- Throws:
SQLException
-
commit
- Specified by:
commit
in interfaceConnection
- Throws:
SQLException
-
rollback
- Specified by:
rollback
in interfaceConnection
- Throws:
SQLException
-
setSchema
- Specified by:
setSchema
in interfaceConnection
- Throws:
SQLException
-
getSchemaTemplate
@Nonnull public com.apple.foundationdb.relational.api.metadata.SchemaTemplate getSchemaTemplate() throws com.apple.foundationdb.relational.api.exceptions.RelationalException- Throws:
com.apple.foundationdb.relational.api.exceptions.RelationalException
-
getMetricCollector
-
getSchema
- Specified by:
getSchema
in interfaceConnection
- Throws:
SQLException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceConnection
- Throws:
SQLException
-
isClosed
- Specified by:
isClosed
in interfaceConnection
- Throws:
SQLException
-
getMetaData
@Nonnull public com.apple.foundationdb.relational.api.RelationalDatabaseMetaData getMetaData() throws SQLException- Specified by:
getMetaData
in interfaceConnection
- Throws:
SQLException
-
setTransactionIsolation
- Specified by:
setTransactionIsolation
in interfaceConnection
- Throws:
SQLException
-
getTransactionIsolation
- Specified by:
getTransactionIsolation
in interfaceConnection
- Throws:
SQLException
-
getWarnings
- Specified by:
getWarnings
in interfaceConnection
- Specified by:
getWarnings
in interfacecom.apple.foundationdb.relational.api.RelationalConnection
- Throws:
SQLException
-
createArrayOf
- Specified by:
createArrayOf
in interfaceConnection
- Throws:
SQLException
-
createStruct
- Specified by:
createStruct
in interfaceConnection
- Throws:
SQLException
-
getOptions
@Nonnull public com.apple.foundationdb.relational.api.Options getOptions()- Specified by:
getOptions
in interfacecom.apple.foundationdb.relational.api.RelationalConnection
-
setOption
public void setOption(com.apple.foundationdb.relational.api.Options.Name name, Object value) throws SQLException - Specified by:
setOption
in interfacecom.apple.foundationdb.relational.api.RelationalConnection
- Throws:
SQLException
-
getPath
- Specified by:
getPath
in interfacecom.apple.foundationdb.relational.api.RelationalConnection
-
getBackingCatalog
-
getTransaction
@Nonnull public Transaction getTransaction() throws com.apple.foundationdb.relational.api.exceptions.RelationalExceptionReturns theTransaction
object if there is one active.- Returns:
- the current transaction.
- Throws:
com.apple.foundationdb.relational.api.exceptions.RelationalException
- if there is no active transaction.
-
getRecordLayerDatabase
-
createNewTransaction
public void createNewTransaction() throws com.apple.foundationdb.relational.api.exceptions.RelationalException, SQLException- Throws:
com.apple.foundationdb.relational.api.exceptions.RelationalException
SQLException
-
getExecuteProperties
-
unwrap
- Specified by:
unwrap
in interfacecom.apple.foundationdb.relational.api.RelationalConnection
- Specified by:
unwrap
in interfaceWrapper
- Throws:
SQLException
-
createStatementBuilderFactory
@Nonnull public com.apple.foundationdb.relational.api.fluentsql.statement.StatementBuilderFactory createStatementBuilderFactory() throws SQLException- Specified by:
createStatementBuilderFactory
in interfacecom.apple.foundationdb.relational.api.RelationalConnection
- Throws:
SQLException
-
createExpressionBuilderFactory
@Nonnull public com.apple.foundationdb.relational.api.fluentsql.expression.ExpressionFactory createExpressionBuilderFactory() throws SQLException- Specified by:
createExpressionBuilderFactory
in interfacecom.apple.foundationdb.relational.api.RelationalConnection
- Throws:
SQLException
-