Class SQLDBConfig

java.lang.Object
org.tribuo.data.sql.SQLDBConfig
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>

public class SQLDBConfig extends Object implements com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>
N.B. This class accepts raw SQL strings and executes them directly via JDBC. It DOES NOT perform any SQL escaping or other injection prevention. It is the user's responsibility to ensure that SQL passed to this class performs as desired.

SQL database configuration. If you specify the host, port, and db strings and use oracle.jdbc.OracleDriver as your JDBC Driver, then this will automatically generate a connectionString, otherwise it must be specified manually and host, port, and db fields can be omitted.

DriverManager's default logic will be used to determine which Driver to use for a given connection string.

  • Constructor Details

    • SQLDBConfig

      public SQLDBConfig(String connectionString, String username, String password, Map<String,String> properties)
      Constructs a SQL database configuration.

      Note it is recommended that wallet based connections are used rather than this constructor using SQLDBConfig(String,Map).

      Parameters:
      connectionString - The connection string.
      username - The username.
      password - The password.
      properties - The connection properties.
    • SQLDBConfig

      public SQLDBConfig(String host, String port, String db, String username, String password, Map<String,String> properties)
      Constructs a SQL database configuration.

      Note it is recommended that wallet based connections are used rather than this constructor using SQLDBConfig(String,Map).

      Parameters:
      host - The host to connect to.
      port - The port to connect on.
      db - The db name.
      username - The username.
      password - The password.
      properties - The connection properties.
    • SQLDBConfig

      public SQLDBConfig(String connectionString, Map<String,String> properties)
      Constructs a SQL database configuration.
      Parameters:
      connectionString - The connection string.
      properties - The connection properties.
  • Method Details

    • postConfig

      public void postConfig()
      Used by the OLCUT configuration system, and should not be called by external code.
      Specified by:
      postConfig in interface com.oracle.labs.mlrg.olcut.config.Configurable
    • getConnection

      public Connection getConnection() throws SQLException
      Constructs a connection based on the object fields.
      Returns:
      A connection to the database.
      Throws:
      SQLException - If the connection failed.
    • getStatement

      public Statement getStatement() throws SQLException
      Constructs a statement based on the object fields. Uses fetchSize to determine fetch size and sets defaults for querying data.
      Returns:
      A statement object for querying the database.
      Throws:
      SQLException - If the connection failed.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getProvenance

      public com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance getProvenance()
      Specified by:
      getProvenance in interface com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>