Interface DbConnection

All Superinterfaces:
AutoCloseable

public interface DbConnection extends AutoCloseable
Connection contract used by SDK implementations to execute SQL and PL/SQL against an Oracle database that has access to DBMS_CLOUD_AI.

DbConnection extends AutoCloseable. A DbConnection instance represents a JDBC-backed database connection used by the SDK. Callers should close the DbConnection when they own it and no longer need it, either by using try-with-resources or by calling close() explicitly.

When a SelectAI client is created from DbConnectionConfig, the SDK owns the underlying JDBC connection and closes it when SelectAI.close() is called. When application code creates or holds a DbConnection directly, that application code is responsible for closing it.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the JDBC connection owned by this DbConnection.
    create(DbConnectionConfig dbConnectionConfig)
    Creates a JDBC-backed DbConnection from database connection configuration.
    Returns the underlying JDBC connection used by SDK operations.
    Returns the database user that owns or invokes the Select AI resources.
    Returns the JDBC URL used to create the underlying connection.
  • Method Details

    • create

      static DbConnection create(DbConnectionConfig dbConnectionConfig) throws SelectAIException
      Creates a JDBC-backed DbConnection from database connection configuration.

      The returned object owns one JDBC connection. Call close() when the connection is no longer needed.

      Parameters:
      dbConnectionConfig - database connection configuration
      Returns:
      initialized DbConnection
      Throws:
      IllegalArgumentException - when dbConnectionConfig is null
      SelectAIException - when the JDBC connection cannot be initialized
    • getJdbcUrl

      Returns the JDBC URL used to create the underlying connection.
      Returns:
      JDBC URL
    • getDbUser

      Returns the database user that owns or invokes the Select AI resources.
      Returns:
      database username
    • getConnection

      Returns the underlying JDBC connection used by SDK operations.

      The returned connection is not a defensive copy. Closing or mutating it directly affects SDK operations that use this DbConnection. Do not share one returned JDBC connection across multiple application threads unless caller-side synchronization is used. For a complete runnable sample source, see GetConnectionSample source.

      Returns:
      JDBC connection
    • close

      void close() throws SelectAIException
      Closes the JDBC connection owned by this DbConnection.

      Calling this method is idempotent for SDK-provided implementations. After close, callers must not continue using SDK objects that depend on this connection. For a complete runnable sample source, see CloseSelectAISample source.

      Specified by:
      close in interface AutoCloseable
      Throws:
      SelectAIException - when the underlying JDBC connection cannot be closed