Interface ConnectionProvider


public interface ConnectionProvider
Supplies JDBC connections for SDK operations.

SDK-provided DataSource-backed implementations obtain a connection lazily for each operation and close it when the operation completes. If the DataSource is pooled, closing normally returns the connection to the pool. The SDK does not own or close the application-provided DataSource.

SDK-provided single-connection implementations reuse one retained JDBC connection for the lifetime of the owning client or connection object. The connection is opened when the owner is created and is closed when the owner is closed.

Connection ownership and cleanup depend on the implementation. A retained connection is closed by its owning SelectAI, DatabaseAdmin, or DbConnection object.

This interface does not define transaction boundaries. SDK-provided implementations do not explicitly commit or roll back transactions and do not change the connection autoCommit setting. Any implicit commit or rollback performed by the underlying Oracle Database API is outside the SDK's transaction management.

Thread safety is implementation-specific and is not guaranteed by this interface. DataSource-backed implementations may support concurrent independent operations according to the DataSource contract. A single-connection implementation should be treated as single-threaded unless the connection owner provides synchronization.

Application code normally obtains SDK clients through public factory methods such as SelectAI.create(javax.sql.DataSource) and SelectAI.create(com.oracle.database.selectai.model.DbConnectionConfig). Concrete provider implementations are internal SDK details.

  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    Executes one SDK operation with a connection supplied by this provider.
  • Method Details

    • withConnection

      Executes one SDK operation with a connection supplied by this provider.

      The callback is invoked synchronously. The callback must close any JDBC resources it creates, such as statements and result sets, but must not close, retain, or use the supplied connection after the callback returns.

      For SDK-provided DataSource implementations, the connection is borrowed for the operation and closed afterward. For SDK-provided single-connection implementations, the connection is reused and remains owned by the configured connection owner.

      Type Parameters:
      T - result type returned by the callback; may be null
      Parameters:
      callback - non-null callback containing the JDBC operation
      Returns:
      result returned by the callback
      Throws:
      IllegalArgumentException - when callback is null
      SQLException - if connection acquisition or a JDBC operation performed by the callback fails
      SelectAIException - when SDK-specific work fails
      RuntimeException - when the callback fails with an unchecked exception