Interface DataSource

  • All Superinterfaces:
    java.lang.AutoCloseable

    public interface DataSource
    extends java.lang.AutoCloseable
    Uses the builder pattern to get a Session. A getSession() method is provided as a convenience. Implementations must be thread safe.
    • Method Detail

      • builder

        Session.Builder builder()
        Returns a Session builder. By default that builder will return Sessions with the SessionPropertys specified when creating this DataSource. Default and unspecified SessionPropertys can be set with the returned builder.
        Returns:
        a new Session builder. Not null.
        Throws:
        java.lang.IllegalStateException - if this DataSource is closed
      • getSession

        default Session getSession()
        Returns a Session that has a submitted attach Operation. Convenience method for use with try with resources.
        Returns:
        a Session
        Throws:
        java.lang.IllegalStateException - if this DataSource is closed
      • getSession

        default Session getSession​(java.util.function.Consumer<java.lang.Throwable> handler)
        Returns a Session that has a submitted attach Operation with an error handler. Convenience method for use with try with resources. The error handle handles errors in the attach Operation.
        Parameters:
        handler - for errors in the attach Operation
        Returns:
        a Session
        Throws:
        java.lang.IllegalStateException - if this DataSource 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 create Operations for the Sessions provided by this DataSource. ISSUE: Just an idea
        Parameters:
        format - not null
        source - SQL in the format specified by format. Not null.
        Returns:
        SQL in the format supported by this DataSource. Not null.
        Throws:
        java.lang.IllegalArgumentException - if the format is not supported or if the DataSource cannot translate the SQL
        java.lang.IllegalStateException - if this DataSource is closed
        SqlException
      • supportedTranslateSqlFormats

        default java.util.List<java.lang.String> supportedTranslateSqlFormats()
        Return a list of the source formats accepted by the translateSql(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 this DataSource is closed
      • close

        void close()
        Specified by:
        close in interface java.lang.AutoCloseable