Package adams.db
Class ConnectionParameters
- java.lang.Object
-
- adams.db.ConnectionParameters
-
- All Implemented Interfaces:
CloneHandler<ConnectionParameters>
,Serializable
,Comparable<ConnectionParameters>
public class ConnectionParameters extends Object implements Serializable, Comparable<ConnectionParameters>, CloneHandler<ConnectionParameters>
Container class for connection information.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_AutoCommit
whether to use auto-commit.protected boolean
m_ConnectOnStartUp
whether to connect on startup.protected LoggingLevel
m_LoggingLevel
the logging level.protected BasePassword
m_Password
the password.protected String
m_URL
the URL.protected String
m_User
the user.static String
PARAM_AUTOCOMMIT
the auto commit.static String
PARAM_CLASS
the class parameter.static String
PARAM_CONNECTONSTARTUP
the connect on startup parameter.static String
PARAM_LOGGINGLEVEL
the logging level parameter.static String
PARAM_PASSWORD
the password parameter.static String
PARAM_URL
the URL parameter.static String
PARAM_USER
the user parameter.
-
Constructor Summary
Constructors Constructor Description ConnectionParameters()
Initializes the container.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(ConnectionParameters o)
Compares this object with the specified object for order.boolean
equals(Object obj)
Indicates whether some other object is "equal to" this one.static ConnectionParameters
forName(String classname)
Creates a new object based on the classname, falls back to the default class, if instantiation fails.boolean
getAutoCommit()
Returns whether to use auto-commit.ConnectionParameters
getClone()
Returns a copy of ifself.boolean
getConnectOnStartUp()
Returns whether to connect on startup.LoggingLevel
getLoggingLevel()
Returns the logging level.String
getParameter(String key)
Returns the parameter for the specified key.BasePassword
getPassword()
Returns the password.String
getURL()
Returns the URL.String
getUser()
Returns the user.int
hashCode()
Hashcode so can be used as hashtable key.protected void
initialize()
Initializes the members.protected ConnectionParameters
newInstance()
Returns a new (empty) instance of a ConnectionParameters object.Enumeration<String>
parameters()
Returns the available parameter keys.void
setParameter(String key, String value)
Sets the parameter for the specified key.AbstractDatabaseConnection
toDatabaseConnection(Class dbcon)
Returns the instance of a new database connection object.String
toString()
Returns a shortened URL.
-
-
-
Field Detail
-
PARAM_CLASS
public static final String PARAM_CLASS
the class parameter.- See Also:
- Constant Field Values
-
PARAM_URL
public static final String PARAM_URL
the URL parameter.- See Also:
- Constant Field Values
-
PARAM_USER
public static final String PARAM_USER
the user parameter.- See Also:
- Constant Field Values
-
PARAM_PASSWORD
public static final String PARAM_PASSWORD
the password parameter.- See Also:
- Constant Field Values
-
PARAM_LOGGINGLEVEL
public static final String PARAM_LOGGINGLEVEL
the logging level parameter.- See Also:
- Constant Field Values
-
PARAM_CONNECTONSTARTUP
public static final String PARAM_CONNECTONSTARTUP
the connect on startup parameter.- See Also:
- Constant Field Values
-
PARAM_AUTOCOMMIT
public static final String PARAM_AUTOCOMMIT
the auto commit.- See Also:
- Constant Field Values
-
m_URL
protected String m_URL
the URL.
-
m_User
protected String m_User
the user.
-
m_Password
protected BasePassword m_Password
the password.
-
m_LoggingLevel
protected LoggingLevel m_LoggingLevel
the logging level.
-
m_ConnectOnStartUp
protected boolean m_ConnectOnStartUp
whether to connect on startup.
-
m_AutoCommit
protected boolean m_AutoCommit
whether to use auto-commit.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.
-
getURL
public String getURL()
Returns the URL.- Returns:
- the URL
-
getUser
public String getUser()
Returns the user.- Returns:
- the user
-
getPassword
public BasePassword getPassword()
Returns the password.- Returns:
- the password
-
getLoggingLevel
public LoggingLevel getLoggingLevel()
Returns the logging level.- Returns:
- the logging level
-
getConnectOnStartUp
public boolean getConnectOnStartUp()
Returns whether to connect on startup.- Returns:
- true if to connect on startup
-
getAutoCommit
public boolean getAutoCommit()
Returns whether to use auto-commit.- Returns:
- true if to use auto-commit
-
parameters
public Enumeration<String> parameters()
Returns the available parameter keys.- Returns:
- the parameter keys
-
getParameter
public String getParameter(String key)
Returns the parameter for the specified key.- Parameters:
key
- the key of the parameter to retrieve- Returns:
- the associated value, null if not available
-
setParameter
public void setParameter(String key, String value)
Sets the parameter for the specified key.- Parameters:
key
- the key of the parameter to setvalue
- the associated value
-
newInstance
protected ConnectionParameters newInstance()
Returns a new (empty) instance of a ConnectionParameters object.- Returns:
- the empty instance
-
getClone
public ConnectionParameters getClone()
Returns a copy of ifself.- Specified by:
getClone
in interfaceCloneHandler<ConnectionParameters>
- Returns:
- the copy
-
compareTo
public int compareTo(ConnectionParameters o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.- Specified by:
compareTo
in interfaceComparable<ConnectionParameters>
- Parameters:
o
- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Throws:
ClassCastException
- if the specified object's type prevents it from being compared to this object.
-
equals
public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.
-
hashCode
public int hashCode()
Hashcode so can be used as hashtable key. Returns the hashcode of the "url \t user \t password" string.
-
toString
public String toString()
Returns a shortened URL.
-
toDatabaseConnection
public AbstractDatabaseConnection toDatabaseConnection(Class dbcon)
Returns the instance of a new database connection object.- Parameters:
dbcon
- the database connection object class to instantiate- Returns:
- the new database connection object
-
forName
public static ConnectionParameters forName(String classname)
Creates a new object based on the classname, falls back to the default class, if instantiation fails.- Parameters:
classname
- the class to instantiate- Returns:
- the new object
-
-