Class SqlDbPropertiesConfig

java.lang.Object
com.persequor.extension.db.SqlDbPropertiesConfig
All Implemented Interfaces:
ISqlDbConfig, DbType

public abstract class SqlDbPropertiesConfig extends Object implements ISqlDbConfig
This class reads ISqlDbConfig from the property file.

Whenever null is returned by any of the getters (e.g. property is not present in a configuration file) , the corresponding SAGA sql connection value will be used instead. You configuration file/environment could contain the following:

 {prefix}.username=xxxx
 {prefix}.password=xxxx
 {prefix}.address=xxxx:yyyy,xxxx
 {prefix}.database-name=xxxx
 

Your own configuration class could look like:

 public class ExtraModuleSqlConfig extends SqlDbPropertiesConfig{

    @Inject
    public ExtraModuleSqlConfig() {
        super("extra-module-prefix");
    }

    @Override
    public String getDefaultDatabaseName() {
        return "module_db";
    }
 }
 
  • Constructor Details

    • SqlDbPropertiesConfig

      protected SqlDbPropertiesConfig(String prefix)
  • Method Details

    • getUsername

      public String getUsername()
      Specified by:
      getUsername in interface ISqlDbConfig
      Returns:
      return username for the SQL database
    • getPassword

      public String getPassword()
      Specified by:
      getPassword in interface ISqlDbConfig
      Returns:
      return password for the provided username
    • getAddress

      public String getAddress()
      Specified by:
      getAddress in interface ISqlDbConfig
      Returns:
      comma separated server address list in form of (host):(port). Example: "myserver:3306,myserver2:3306"
    • getDatabaseName

      public final String getDatabaseName()
      Description copied from interface: ISqlDbConfig
      This must be different from that of SAGA and other SAGA Modules.
      Specified by:
      getDatabaseName in interface ISqlDbConfig
      Returns:
      the unique database/tablespace used by this connection
    • getDatabaseParams

      public String getDatabaseParams()
      Specified by:
      getDatabaseParams in interface ISqlDbConfig
      Returns:
      ampersand (&) separated path parameters of JDBC URL Example: "myParam=true&mySecondParam=aValue"
    • getDefaultDatabaseName

      public abstract String getDefaultDatabaseName()
      You must return a default database to be used when SAGA is run without configuration files.
      Returns:
      the default database to use.