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 to autoCommit being set to true since the Connection.commit() and Connection.rollback() wont be applicable. However, all statements run within the external transaction. For internal usage, the consumer should check canCommit() to see if they are allowed to manage a transaction.
  • 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 interface Connection
      Specified by:
      createStatement in interface com.apple.foundationdb.relational.api.RelationalConnection
      Throws:
      SQLException
    • prepareStatement

      public com.apple.foundationdb.relational.api.RelationalPreparedStatement prepareStatement(String sql) throws SQLException
      Specified by:
      prepareStatement in interface Connection
      Specified by:
      prepareStatement in interface com.apple.foundationdb.relational.api.RelationalConnection
      Throws:
      SQLException
    • setReadOnly

      public void setReadOnly(boolean readOnly) throws SQLException
      Specified by:
      setReadOnly in interface Connection
      Specified by:
      setReadOnly in interface com.apple.foundationdb.relational.api.RelationalConnection
      Throws:
      SQLException
    • setAutoCommit

      public void setAutoCommit(boolean autoCommit) throws SQLException
      Specified by:
      setAutoCommit in interface Connection
      Throws:
      SQLException
    • getAutoCommit

      public boolean getAutoCommit() throws SQLException
      Specified by:
      getAutoCommit in interface Connection
      Throws:
      SQLException
    • commit

      public void commit() throws SQLException
      Specified by:
      commit in interface Connection
      Throws:
      SQLException
    • rollback

      public void rollback() throws SQLException
      Specified by:
      rollback in interface Connection
      Throws:
      SQLException
    • setSchema

      public void setSchema(String schema) throws SQLException
      Specified by:
      setSchema in interface Connection
      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

      @Nullable public MetricCollector getMetricCollector()
    • getSchema

      public String getSchema() throws SQLException
      Specified by:
      getSchema in interface Connection
      Throws:
      SQLException
    • close

      public void close() throws SQLException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Connection
      Throws:
      SQLException
    • isClosed

      public boolean isClosed() throws SQLException
      Specified by:
      isClosed in interface Connection
      Throws:
      SQLException
    • getMetaData

      @Nonnull public com.apple.foundationdb.relational.api.RelationalDatabaseMetaData getMetaData() throws SQLException
      Specified by:
      getMetaData in interface Connection
      Throws:
      SQLException
    • setTransactionIsolation

      public void setTransactionIsolation(int level) throws SQLException
      Specified by:
      setTransactionIsolation in interface Connection
      Throws:
      SQLException
    • getTransactionIsolation

      public int getTransactionIsolation() throws SQLException
      Specified by:
      getTransactionIsolation in interface Connection
      Throws:
      SQLException
    • getWarnings

      public SQLWarning getWarnings() throws SQLException
      Specified by:
      getWarnings in interface Connection
      Specified by:
      getWarnings in interface com.apple.foundationdb.relational.api.RelationalConnection
      Throws:
      SQLException
    • createArrayOf

      public Array createArrayOf(String typeName, Object[] elements) throws SQLException
      Specified by:
      createArrayOf in interface Connection
      Throws:
      SQLException
    • createStruct

      public Struct createStruct(String typeName, Object[] attributes) throws SQLException
      Specified by:
      createStruct in interface Connection
      Throws:
      SQLException
    • getOptions

      @Nonnull public com.apple.foundationdb.relational.api.Options getOptions()
      Specified by:
      getOptions in interface com.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 interface com.apple.foundationdb.relational.api.RelationalConnection
      Throws:
      SQLException
    • getPath

      public URI getPath()
      Specified by:
      getPath in interface com.apple.foundationdb.relational.api.RelationalConnection
    • getBackingCatalog

      @Nonnull public StoreCatalog getBackingCatalog()
    • getTransaction

      @Nonnull public Transaction getTransaction() throws com.apple.foundationdb.relational.api.exceptions.RelationalException
      Returns the Transaction 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

      @Nonnull public AbstractDatabase getRecordLayerDatabase()
    • createNewTransaction

      public void createNewTransaction() throws com.apple.foundationdb.relational.api.exceptions.RelationalException, SQLException
      Throws:
      com.apple.foundationdb.relational.api.exceptions.RelationalException
      SQLException
    • getExecuteProperties

      @Nonnull public ExecuteProperties getExecuteProperties()
    • unwrap

      @Nonnull public <T> T unwrap(Class<T> iface) throws SQLException
      Specified by:
      unwrap in interface com.apple.foundationdb.relational.api.RelationalConnection
      Specified by:
      unwrap in interface Wrapper
      Throws:
      SQLException
    • createStatementBuilderFactory

      @Nonnull public com.apple.foundationdb.relational.api.fluentsql.statement.StatementBuilderFactory createStatementBuilderFactory() throws SQLException
      Specified by:
      createStatementBuilderFactory in interface com.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 interface com.apple.foundationdb.relational.api.RelationalConnection
      Throws:
      SQLException