Class FailoverConfig

java.lang.Object
com.adaptris.jdbc.connection.FailoverConfig
All Implemented Interfaces:
Cloneable

public final class FailoverConfig extends Object implements Cloneable
Class that is used to configure a failover database connection.
See Also:
  • Field Details

  • Constructor Details

    • FailoverConfig

      public FailoverConfig()
      See Also:
    • FailoverConfig

      public FailoverConfig(Properties map)
      Constructor using a pre-existing map.

      This allows us to easily configure the repository from a set of properties.

      The properties object is expected to contain the following keys with associated values

      • jdbc.driver.classname - this represents the jdbc driver classname
      • jdbc.driver.url.n - where n is some unique identifier. Each of these entries will specify a database connection string in the general form jdbc:mysql://localhost:3306/portal. There must be at least one of these entries. Each entry is used to as a parameter to FailoverConfig.addConnectionUrl(String s)
      • jdbc.driver.autocommit - either true or false, the default is true
      • jdbc.username - the username for the connection - this is optional, if all connection urls have a username/password inline.
      • jdbc.password - password for the connection - this is optional, if all connection urls have a username/password inline.

      If there is more than one jdbc.driver.url key then the natural ordering of the keys is used to specify the order in which urls are added to the FailoverConfig object.

      An Example property file would be:-

       
       jdbc.driver.classname=com.mysql.jdbc.Driver
       jdbc.driver.url.1=jdbc:mysql://master:3306/portal?user=user
       jdbc.driver.url.2=jdbc:mysql://slave1:3306/portal?user=user
       jdbc.driver.url.3=jdbc:mysql://slave2:3306/portal?user=user
       
       
      Parameters:
      map - the Map from which we will initialise from.
      See Also:
  • Method Details

    • setConnectionUrls

      public void setConnectionUrls(List<String> list)
      Set a Connection URL to the configured list.
      Parameters:
      list - a list of connection urls
      Throws:
      IllegalArgumentException - if the string is null.
    • addConnectionUrl

      public void addConnectionUrl(String string)
      Add a Connection URL to the configured list.
      Parameters:
      string - a connection url
      Throws:
      IllegalArgumentException - if the string is null.
    • getConnectionUrls

      public List<String> getConnectionUrls()
      Get the configured list of URLs.
      Returns:
      The configured collection of urls
    • getDatabaseDriver

      public String getDatabaseDriver()
      Get the configured database Driver for this config
      Returns:
      the database driver
    • setDatabaseDriver

      public void setDatabaseDriver(String string)
      Set the database driver.
      Parameters:
      string - the database driver
      Throws:
      IllegalArgumentException - if the driver is null.
    • getTestStatement

      public String getTestStatement()
      Get the statement that will test the connection.
      Returns:
      the statement
    • setTestStatement

      public void setTestStatement(String string) throws IllegalArgumentException
      Set the statement that will test the connection.
      Parameters:
      string - the statement
      Throws:
      IllegalArgumentException - if the statement is null.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
      See Also:
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      See Also:
    • toString

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

      public boolean getAutoCommit()
      Get autoCommit flag for this configuration
      Returns:
      the autoCommit flag
    • setAutoCommit

      public void setAutoCommit(boolean b)
      Set the autocommit flag for this configuration
      Parameters:
      b - the new flag
    • getDebugMode

      public boolean getDebugMode()
      Return whether the database connection should have further verbose logging.
      Returns:
      true or false.
    • setDebugMode

      public void setDebugMode(boolean b)
      Specify verbose logging.
      Parameters:
      b - true or false.
    • clone

      public Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
      See Also:
    • getAlwaysValidateConnection

      public boolean getAlwaysValidateConnection()
    • setAlwaysValidateConnection

      public void setAlwaysValidateConnection(boolean b)
    • getUsername

      public String getUsername()
    • setUsername

      public void setUsername(String username)
    • getPassword

      public String getPassword()
    • setPassword

      public void setPassword(String password)
    • getConnectionProperties

      public Properties getConnectionProperties()
    • setConnectionProperties

      public void setConnectionProperties(Properties p)