public final class FailoverConfig
extends java.lang.Object
implements java.lang.Cloneable
FailoverConnection
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
JDBC_ALWAYS_VERIFY
resource key for connection verify setting
|
static java.lang.String |
JDBC_AUTO_COMMIT
resource key for driver autocommit setting
|
static java.lang.String |
JDBC_DEBUG
resource key specifying extra debug.
|
static java.lang.String |
JDBC_DRIVER
resource key for driver classname
|
static java.lang.String |
JDBC_PASSWORD
resource key for specifying the password
|
static java.lang.String |
JDBC_TEST_STATEMENT
Resource key for testing a connection.
|
static java.lang.String |
JDBC_URL_ROOT
resource key for driver url
|
static java.lang.String |
JDBC_USERNAME
resource key for specifying the username
|
Constructor and Description |
---|
FailoverConfig() |
FailoverConfig(java.util.Properties map)
Constructor using a pre-existing map.
|
Modifier and Type | Method and Description |
---|---|
void |
addConnectionUrl(java.lang.String string)
Add a Connection URL to the configured list.
|
java.lang.Object |
clone() |
boolean |
equals(java.lang.Object o) |
boolean |
getAlwaysValidateConnection() |
boolean |
getAutoCommit()
Get autoCommit flag for this configuration
|
java.util.Properties |
getConnectionProperties() |
java.util.List<java.lang.String> |
getConnectionUrls()
Get the configured list of URLs.
|
java.lang.String |
getDatabaseDriver()
Get the configured database Driver for this config
|
boolean |
getDebugMode()
Return whether the database connection should have further verbose logging.
|
java.lang.String |
getPassword() |
java.lang.String |
getTestStatement()
Get the statement that will test the connection.
|
java.lang.String |
getUsername() |
int |
hashCode() |
void |
setAlwaysValidateConnection(boolean b) |
void |
setAutoCommit(boolean b)
Set the autocommit flag for this configuration
|
void |
setConnectionProperties(java.util.Properties p) |
void |
setConnectionUrls(java.util.List<java.lang.String> list)
Set a Connection URL to the configured list.
|
void |
setDatabaseDriver(java.lang.String string)
Set the database driver.
|
void |
setDebugMode(boolean b)
Specify verbose logging.
|
void |
setPassword(java.lang.String password) |
void |
setTestStatement(java.lang.String string)
Set the statement that will test the connection.
|
void |
setUsername(java.lang.String username) |
java.lang.String |
toString() |
public static final java.lang.String JDBC_DRIVER
public static final java.lang.String JDBC_TEST_STATEMENT
public static final java.lang.String JDBC_URL_ROOT
public static final java.lang.String JDBC_AUTO_COMMIT
public static final java.lang.String JDBC_ALWAYS_VERIFY
public static final java.lang.String JDBC_DEBUG
public static final java.lang.String JDBC_USERNAME
public static final java.lang.String JDBC_PASSWORD
public FailoverConfig()
Object()
public FailoverConfig(java.util.Properties 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: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)
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
map
- the Map
from which we will initialise from.JDBC_DRIVER
,
JDBC_URL_ROOT
,
addConnectionUrl(String)
public void setConnectionUrls(java.util.List<java.lang.String> list)
list
- a list of connection urlsjava.lang.IllegalArgumentException
- if the string is null.public void addConnectionUrl(java.lang.String string)
string
- a connection urljava.lang.IllegalArgumentException
- if the string is null.public java.util.List<java.lang.String> getConnectionUrls()
public java.lang.String getDatabaseDriver()
public void setDatabaseDriver(java.lang.String string)
string
- the database driverjava.lang.IllegalArgumentException
- if the driver is null.public java.lang.String getTestStatement()
public void setTestStatement(java.lang.String string) throws java.lang.IllegalArgumentException
string
- the statementjava.lang.IllegalArgumentException
- if the statement is null.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
Object.equals(java.lang.Object)
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean getAutoCommit()
public void setAutoCommit(boolean b)
b
- the new flagpublic boolean getDebugMode()
public void setDebugMode(boolean b)
b
- true or false.public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
Object.clone()
public boolean getAlwaysValidateConnection()
public void setAlwaysValidateConnection(boolean b)
public java.lang.String getUsername()
public void setUsername(java.lang.String username)
public java.lang.String getPassword()
public void setPassword(java.lang.String password)
public java.util.Properties getConnectionProperties()
public void setConnectionProperties(java.util.Properties p)