Package com.adaptris.jdbc.connection
Class FailoverConfig
java.lang.Object
com.adaptris.jdbc.connection.FailoverConfig
- All Implemented Interfaces:
Cloneable
Class that is used to configure a failover database connection.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
resource key for connection verify settingstatic final String
resource key for driver autocommit settingstatic final String
resource key specifying extra debug.static final String
resource key for driver classnamestatic final String
resource key for specifying the passwordstatic final String
Resource key for testing a connection.static final String
resource key for driver urlstatic final String
resource key for specifying the username -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConnectionUrl
(String string) Add a Connection URL to the configured list.clone()
boolean
boolean
boolean
Get autoCommit flag for this configurationGet the configured list of URLs.Get the configured database Driver for this configboolean
Return whether the database connection should have further verbose logging.Get the statement that will test the connection.int
hashCode()
void
setAlwaysValidateConnection
(boolean b) void
setAutoCommit
(boolean b) Set the autocommit flag for this configurationvoid
void
setConnectionUrls
(List<String> list) Set a Connection URL to the configured list.void
setDatabaseDriver
(String string) Set the database driver.void
setDebugMode
(boolean b) Specify verbose logging.void
setPassword
(String password) void
setTestStatement
(String string) Set the statement that will test the connection.void
setUsername
(String username) toString()
-
Field Details
-
JDBC_DRIVER
resource key for driver classname- See Also:
-
JDBC_TEST_STATEMENT
Resource key for testing a connection.- See Also:
-
JDBC_URL_ROOT
resource key for driver url- See Also:
-
JDBC_AUTO_COMMIT
resource key for driver autocommit setting- See Also:
-
JDBC_ALWAYS_VERIFY
resource key for connection verify setting- See Also:
-
JDBC_DEBUG
resource key specifying extra debug.- See Also:
-
JDBC_USERNAME
resource key for specifying the username- See Also:
-
JDBC_PASSWORD
resource key for specifying the password- See Also:
-
-
Constructor Details
-
FailoverConfig
public FailoverConfig()- See Also:
-
FailoverConfig
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 theFailoverConfig
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
- theMap
from which we will initialise from.- See Also:
-
-
Method Details
-
setConnectionUrls
Set a Connection URL to the configured list.- Parameters:
list
- a list of connection urls- Throws:
IllegalArgumentException
- if the string is null.
-
addConnectionUrl
Add a Connection URL to the configured list.- Parameters:
string
- a connection url- Throws:
IllegalArgumentException
- if the string is null.
-
getConnectionUrls
Get the configured list of URLs.- Returns:
- The configured collection of urls
-
getDatabaseDriver
Get the configured database Driver for this config- Returns:
- the database driver
-
setDatabaseDriver
Set the database driver.- Parameters:
string
- the database driver- Throws:
IllegalArgumentException
- if the driver is null.
-
getTestStatement
Get the statement that will test the connection.- Returns:
- the statement
-
setTestStatement
Set the statement that will test the connection.- Parameters:
string
- the statement- Throws:
IllegalArgumentException
- if the statement is null.
-
equals
-
hashCode
public int hashCode() -
toString
-
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
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
- See Also:
-
getAlwaysValidateConnection
public boolean getAlwaysValidateConnection() -
setAlwaysValidateConnection
public void setAlwaysValidateConnection(boolean b) -
getUsername
-
setUsername
-
getPassword
-
setPassword
-
getConnectionProperties
-
setConnectionProperties
-