oracle.dbtools.plugin.api.jdbc

## Interface JDBCDataSource

- All Superinterfaces:
    Function<String,Connection>, Iterable<String>

      public interface JDBCDataSource
      extends Iterable<String>, Function<String,Connection>

  Provides information about a `DataSource`
  Author:
    cdivilly
  See Also:
    `JDBCDataSources`

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default Connection` | `apply(String schema)` Obtains a connection for the specified schema.
    `boolean` | `authenticate(String username, char[] password)` Authenticates the specified user against this data source.
    `Connection` | `connection(String schema)` Provides a `Connection` to the named schema, IFF the schema is available
    `default Iterator<String>` | `iterator()`
    `Iterable<String>` | `schemas()` Enumerates the available JDBC schemas for a given `JDBCDataSource`, to which a `Connection` may be opened
    `static RuntimeException` | `wrap(SQLException e)`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

    - ### Methods inherited from interface java.util.function.Function

      `andThen, compose, identity`

- - ### Method Detail

    - #### apply

          default Connection apply(String schema)
                            throws IllegalArgumentException,
                                   IllegalStateException,
                                   RuntimeException

      Obtains a connection for the specified schema.
      Specified by:
        `apply` in interface `Function<String,Connection>`
      Returns:
        the connection if available
      Throws:
        `IllegalArgumentException` - if the schema is not found. The cause is an `SQLTransientConnectionException` with a SQL State of `08003`
        `IllegalStateException` - if the connection creation was rejected by the server. The cause is an `SQLTransientConnectionException` with a SQL State of `08004`
        `RuntimeException` - if the client cloud not connect to the server. The cause is an `SQLTransientConnectionException` with a SQL State of `08001`

    - #### connection

          Connection connection(String schema)
                         throws SchemaNotAvailableException,
                                SQLException

      Provides a `Connection` to the named schema, IFF the schema is available
      Parameters:
        `schema` - The name of the schema to connect to
      Returns:
        `Connection` instance pointing to the schema
      Throws:
        `SchemaNotAvailableException` - if the requested schema does not exist or is not available
        `SQLException` - if an error occurs connecting to the requested schema

    - #### authenticate

          boolean authenticate(String username,
                               char[] password)

      Authenticates the specified user against this data source.
      Parameters:
        `username` - - the database user
        `password` - - the password
      Returns:
        true if the authentication is successful

    - #### iterator

          default Iterator<String> iterator()

      Specified by:
        `iterator` in interface `Iterable<String>`

    - #### schemas

          Iterable<String> schemas()
                            throws SQLException

      Enumerates the available JDBC schemas for a given `JDBCDataSource`, to which a `Connection` may be opened
      Returns:
        Set of schema names
      Throws:
        `SQLException` - if an error occurs while processing this request

    - #### wrap

          static RuntimeException wrap(SQLException e)

Copyright © 2010, 2022, Oracle and/or its affiliates.