Package adams.db
Class AbstractDatabaseConnection
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.db.AbstractDatabaseConnection
-
- All Implemented Interfaces:
CloneHandler<AbstractDatabaseConnection>
,Destroyable
,LoggingSupporter
,OptionHandler
,PasswordSupporter
,SizeOfHandler
,DatabaseConnectionParameterHandler
,Serializable
,Comparable<AbstractDatabaseConnection>
- Direct Known Subclasses:
AbstractReconnectableDatabaseConnection
,DatabaseConnection
public abstract class AbstractDatabaseConnection extends LoggingObject implements OptionHandler, DatabaseConnectionParameterHandler, Comparable<AbstractDatabaseConnection>, CloneHandler<AbstractDatabaseConnection>, PasswordSupporter
DatabaseConnection manages the interface to the database back-end. Currently set up for MYSQL.- Author:
- dale (dale at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_AutoCommit
autocommit?protected HashSet<DatabaseConnectionChangeListener>
m_ChangeListeners
the listeners in case of connect/disconnect.protected Connection
m_Connection
The database connection.protected boolean
m_ConnectionOK
whether we could connect successfully.protected boolean
m_ConnectOnStartUp
whether to connect on startup.protected AbstractEnvironment
m_Environment
the environment to use.protected static HashMap<Class,AbstractEnvironment>
m_Environments
keeping track of environment instances.protected Hashtable<String,Integer>
m_FailedConnectAttempts
for keeping track of unsuccessful connection attempts.protected String
m_LastConnectionError
stores the last connection error.protected int
m_MaxConnectAttempts
the maximum number of allowed connection attempts for a driver/URL/user/pw combination.protected OptionManager
m_OptionManager
for managing the available options.protected DatabaseManager
m_Owner
the database manager this connection belongs to.protected BasePassword
m_Password
database password.protected Properties
m_Properties
the properties for database access.protected static Map<Class,Properties>
m_PropertiesCache
protected int
m_ReconnectWait
the number of seconds to wait before trying to reconnect.protected String
m_URL
the URL to connect to the database.protected String
m_User
database username.static String
PREFIX_CONNECTION
the prefix in the props file for connections.static String
SUFFIX_COUNT
the suffix in the props file for the number of connections.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractDatabaseConnection()
Constructor, uses the default settings.protected
AbstractDatabaseConnection(String url, String user, BasePassword password)
Local Database Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addChangeListener(DatabaseConnectionChangeListener l)
Adds a listener for connect/disconnect events to the internal list.boolean
addConnectionParameters(ConnectionParameters conn)
Adds the given connection to the props file.String
autoCommitTipText()
Returns the tip text for this property.void
cleanUpOptions()
Cleans up the options.int
compareTo(AbstractDatabaseConnection o)
Compares this object with the specified object for order.int
compareTo(ConnectionParameters o)
Compares this object with the specified object for order.protected void
configureLogger()
Initializes the logger.boolean
connect()
Try to make a connection to the database, with the url,username and password.protected boolean
connectionsToProperties(List<ConnectionParameters> connections)
Replaces the current connections with the provided ones and updates the .props file.String
connectOnStartUpTipText()
Returns the tip text for this property.protected abstract AbstractEnvironment
createEnvironment()
Creates a new instance of the environment object that we require.void
defineOptions()
Adds options to the internal list of options.void
destroy()
Frees up memory in a "destructive" non-reversible way.boolean
disconnect()
Attempt disconnect from db.boolean
equals(Object o)
Checks wether this object is the same as the provided one.protected void
finishInit()
Finishes the initialization.List<ConnectionParameters>
getAllConnectionParameters()
Returns the stored connections.boolean
getAutoCommit()
Returns whether to use auto-commit.Set<DatabaseConnectionChangeListener>
getChangeListeners()
Returns the change listeners data structure.AbstractDatabaseConnection
getClone()
Returns a clone of the object.Connection
getConnection(boolean keepTrying)
Return db connection.boolean
getConnectOnStartUp()
Returns whether to use connect on start-up.ConnectionParameters
getCurrentConnectionParameters()
Returns the current connection parameters.boolean
getDefaultAutoCommit()
Returns whether to use auto-commit.ConnectionParameters
getDefaultConnectionParameters()
Returns the default connection parameter object.boolean
getDefaultConnectOnStartUp()
Returns whether to automatically connect on startup, i.e., when obtaining the singleton for the first time.LoggingLevel
getDefaultLoggingLevel()
Returns the logging level specified in the props file.int
getDefaultMaxConnectAttempts()
Returns the maximum number of connection attempts.BasePassword
getDefaultPassword()
Returns the password specified in the props file.int
getDefaultReconnectWait()
Returns the number of seconds to wait before trying to reconnect.String
getDefaultURL()
Returns the database URL specified in the props file.String
getDefaultUser()
Returns the user specified in the props file.protected abstract String
getDefinitionKey()
Returns the properties key to use for retrieving the properties.protected AbstractEnvironment
getEnvironment()
Returns the environment instance to use, creates it if necessary.protected int
getFailedConnectAttempt(String url, String user, BasePassword password)
Returns the failed attempt count for the given connection.protected String
getFailedConnectAttemptKey(String url, String user, BasePassword password)
Generates a key for the failed connect attempt hashtable.String
getLastConnectionError()
Returns the last error that happened when connecting to the database.int
getMaxConnectAttempts()
Returns the maximum number of connection attempts for a driver/URL/user/pw combination.OptionManager
getOptionManager()
Returns the option manager.DatabaseManager
getOwner()
Returns the current database manager that owns this connection.BasePassword
getPassword()
Returns the currently set database password.Properties
getProperties()
Returns the properties, loads them on demand.int
getReconnectWait()
Returns the number of seconds to wait before trying to reconnect.String
getURL()
Returns the currently set database URL.String
getUser()
Returns the currently set database user.int
hashCode()
Hashcode so can be used as hashtable key.protected void
incFailedConnectAttempt(String url, String user, BasePassword password)
Increments the failed attempt for the given connection.protected void
initialize()
initializes member variables.boolean
isConnected()
Is database connected?boolean
isConnectionOK()
Returns if connection to database is OK.String
loggingLevelTipText()
Returns the tip text for this property.boolean
makeDefaultConnection(ConnectionParameters conn)
Sets the given connection as the default one.String
maxConnectAttemptsTipText()
Returns the tip text for this property.ConnectionParameters
newConnectionParameters()
Returns a new instance of a ConnectionParameters object.protected OptionManager
newOptionManager()
Returns a new instance of the option manager.void
notifyChangeListeners(DatabaseConnectionChangeEvent e)
Notifies all listeners with the given event.protected void
outputChangeListeners()
Outputs the change listeners if debugging is on.String
passwordTipText()
Returns the tip text for this property.protected Properties
readProperties()
Reads the properties.String
reconnectWaitTipText()
Returns the tip text for this property.void
removeChangeListener(DatabaseConnectionChangeListener l)
Removes a listener for connect/disconnect events from the internal list.boolean
removeConnectionParameters(ConnectionParameters conn)
Removes the given connection from the props file.void
resetFailedConnectAttempt()
Resets the failed attempts for the current connection.protected void
resetFailedConnectAttempt(String url, String user, BasePassword password)
Resets the failed attempt for the given connection.boolean
retryConnect()
Redo connection to database.void
setAutoCommit(boolean value)
Sets whether to use auto-commit.void
setConnectOnStartUp(boolean value)
Sets whether to connect on start-up (only if not connected).void
setDefaultAutoCommit(boolean value)
Sets the default for auto-commit.void
setDefaultConnectOnStartUp(boolean value)
Sets the default for whether to connect on startup.void
setDefaultLoggingLevel(LoggingLevel value)
Sets the default logging level in the props file.void
setDefaultPassword(BasePassword value)
Sets the default password in the props file.void
setDefaultURL(String value)
Sets the default database URL in the props file.void
setDefaultUser(String value)
Sets the default user in the props file.void
setLoggingLevel(LoggingLevel value)
Sets the logging level.void
setMaxConnectAttempts(int value)
Sets the maximum number of connection attempts for a driver/URL/user/pw combination (only if not connected).void
setOwner(DatabaseManager value)
Sets the database manager that owns this connection.void
setPassword(BasePassword value)
Sets the database password to use (only if not connected).void
setReconnectWait(int value)
Sets the number of seconds to wait before trying to reconnect.void
setURL(String value)
Sets the database URL to use (only if not connected).void
setUser(String value)
Sets the database user to use (only if not connected).String
toCommandLine()
Returns the commandline string.ConnectionParameters
toConnectionParameters(AbstractDatabaseConnection conn)
Turns the database connection into a parameters object.String
toString()
Returns a string representation of the connection object.String
toStringShort()
Returns a short string representation of the connection.protected boolean
tryConnection()
Tries to reconnect.boolean
updateConnectionParameters()
Updates the props file in the project's home directory.String
URLTipText()
Returns the tip text for this property.String
userTipText()
Returns the tip text for this property.-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
PREFIX_CONNECTION
public static final String PREFIX_CONNECTION
the prefix in the props file for connections.- See Also:
- Constant Field Values
-
SUFFIX_COUNT
public static final String SUFFIX_COUNT
the suffix in the props file for the number of connections.- See Also:
- Constant Field Values
-
m_Environments
protected static HashMap<Class,AbstractEnvironment> m_Environments
keeping track of environment instances.
-
m_PropertiesCache
protected static Map<Class,Properties> m_PropertiesCache
-
m_OptionManager
protected OptionManager m_OptionManager
for managing the available options.
-
m_ChangeListeners
protected transient HashSet<DatabaseConnectionChangeListener> m_ChangeListeners
the listeners in case of connect/disconnect.
-
m_Properties
protected Properties m_Properties
the properties for database access.
-
m_FailedConnectAttempts
protected Hashtable<String,Integer> m_FailedConnectAttempts
for keeping track of unsuccessful connection attempts.
-
m_URL
protected String m_URL
the URL to connect to the database.
-
m_User
protected String m_User
database username.
-
m_Password
protected BasePassword m_Password
database password.
-
m_ConnectOnStartUp
protected boolean m_ConnectOnStartUp
whether to connect on startup.
-
m_MaxConnectAttempts
protected int m_MaxConnectAttempts
the maximum number of allowed connection attempts for a driver/URL/user/pw combination.
-
m_ReconnectWait
protected int m_ReconnectWait
the number of seconds to wait before trying to reconnect.
-
m_AutoCommit
protected boolean m_AutoCommit
autocommit?
-
m_Connection
protected transient Connection m_Connection
The database connection.
-
m_ConnectionOK
protected boolean m_ConnectionOK
whether we could connect successfully.
-
m_LastConnectionError
protected String m_LastConnectionError
stores the last connection error.
-
m_Owner
protected DatabaseManager m_Owner
the database manager this connection belongs to.
-
m_Environment
protected transient AbstractEnvironment m_Environment
the environment to use.
-
-
Constructor Detail
-
AbstractDatabaseConnection
protected AbstractDatabaseConnection()
Constructor, uses the default settings.
-
AbstractDatabaseConnection
protected AbstractDatabaseConnection(String url, String user, BasePassword password)
Local Database Constructor. Initialise the JDBC driver, and attempt connection to the database specified in the URL, with the given username and password.- Parameters:
url
- the JDBC URLuser
- the user to connect withpassword
- the password for the user
-
-
Method Detail
-
initialize
protected void initialize()
initializes member variables.
-
finishInit
protected void finishInit()
Finishes the initialization.
-
setOwner
public void setOwner(DatabaseManager value)
Sets the database manager that owns this connection.- Parameters:
value
- the manager
-
getOwner
public DatabaseManager getOwner()
Returns the current database manager that owns this connection.- Returns:
- the manager
-
getChangeListeners
public Set<DatabaseConnectionChangeListener> getChangeListeners()
Returns the change listeners data structure. Initializes it if necessary.- Returns:
- the change listeners
-
newOptionManager
protected OptionManager newOptionManager()
Returns a new instance of the option manager.- Returns:
- the manager to use
-
defineOptions
public void defineOptions()
Adds options to the internal list of options. Derived classes must override this method to add additional options.- Specified by:
defineOptions
in interfaceOptionHandler
-
getOptionManager
public OptionManager getOptionManager()
Returns the option manager.- Specified by:
getOptionManager
in interfaceOptionHandler
- Returns:
- the manager
-
cleanUpOptions
public void cleanUpOptions()
Cleans up the options.- Specified by:
cleanUpOptions
in interfaceOptionHandler
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.
Cleans up the options.- Specified by:
destroy
in interfaceDestroyable
- See Also:
cleanUpOptions()
-
getDefinitionKey
protected abstract String getDefinitionKey()
Returns the properties key to use for retrieving the properties.- Returns:
- the key
-
createEnvironment
protected abstract AbstractEnvironment createEnvironment()
Creates a new instance of the environment object that we require.- Returns:
- the instance
-
getEnvironment
protected AbstractEnvironment getEnvironment()
Returns the environment instance to use, creates it if necessary.- Returns:
- the instance
-
readProperties
protected Properties readProperties()
Reads the properties.- Returns:
- the properties
- See Also:
getDefinitionKey()
-
getProperties
public Properties getProperties()
Returns the properties, loads them on demand.- Returns:
- the properties
-
getDefaultLoggingLevel
public LoggingLevel getDefaultLoggingLevel()
Returns the logging level specified in the props file.- Returns:
- the default logging level
-
setDefaultLoggingLevel
public void setDefaultLoggingLevel(LoggingLevel value)
Sets the default logging level in the props file.- Parameters:
value
- the default logging level
-
setLoggingLevel
public void setLoggingLevel(LoggingLevel value)
Sets the logging level.- Parameters:
value
- the level
-
loggingLevelTipText
public String loggingLevelTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
configureLogger
protected void configureLogger()
Initializes the logger.- Overrides:
configureLogger
in classLoggingObject
-
getDefaultURL
public String getDefaultURL()
Returns the database URL specified in the props file.- Returns:
- the default URL, if any
-
setDefaultURL
public void setDefaultURL(String value)
Sets the default database URL in the props file.- Parameters:
value
- the default URL
-
getURL
public String getURL()
Returns the currently set database URL.- Specified by:
getURL
in interfaceDatabaseConnectionParameterHandler
- Returns:
- the current URL
-
setURL
public void setURL(String value)
Sets the database URL to use (only if not connected).- Specified by:
setURL
in interfaceDatabaseConnectionParameterHandler
- Parameters:
value
- the URL to use
-
URLTipText
public String URLTipText()
Returns the tip text for this property.- Specified by:
URLTipText
in interfaceDatabaseConnectionParameterHandler
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getDefaultUser
public String getDefaultUser()
Returns the user specified in the props file.- Returns:
- the default user, if any
-
setDefaultUser
public void setDefaultUser(String value)
Sets the default user in the props file.- Parameters:
value
- the default user
-
getUser
public String getUser()
Returns the currently set database user.- Specified by:
getUser
in interfaceDatabaseConnectionParameterHandler
- Returns:
- the current user
-
setUser
public void setUser(String value)
Sets the database user to use (only if not connected).- Specified by:
setUser
in interfaceDatabaseConnectionParameterHandler
- Parameters:
value
- the user to use
-
userTipText
public String userTipText()
Returns the tip text for this property.- Specified by:
userTipText
in interfaceDatabaseConnectionParameterHandler
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getDefaultPassword
public BasePassword getDefaultPassword()
Returns the password specified in the props file.- Returns:
- the default password, if any
-
setDefaultPassword
public void setDefaultPassword(BasePassword value)
Sets the default password in the props file.- Parameters:
value
- the default password
-
getPassword
public BasePassword getPassword()
Returns the currently set database password.- Specified by:
getPassword
in interfaceDatabaseConnectionParameterHandler
- Specified by:
getPassword
in interfacePasswordSupporter
- Returns:
- the current password
-
setPassword
public void setPassword(BasePassword value)
Sets the database password to use (only if not connected).- Specified by:
setPassword
in interfaceDatabaseConnectionParameterHandler
- Specified by:
setPassword
in interfacePasswordSupporter
- Parameters:
value
- the password to use
-
passwordTipText
public String passwordTipText()
Returns the tip text for this property.- Specified by:
passwordTipText
in interfaceDatabaseConnectionParameterHandler
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getMaxConnectAttempts
public int getMaxConnectAttempts()
Returns the maximum number of connection attempts for a driver/URL/user/pw combination.- Returns:
- the max number
-
setMaxConnectAttempts
public void setMaxConnectAttempts(int value)
Sets the maximum number of connection attempts for a driver/URL/user/pw combination (only if not connected).- Parameters:
value
- the max number
-
getDefaultMaxConnectAttempts
public int getDefaultMaxConnectAttempts()
Returns the maximum number of connection attempts.- Returns:
- the default maximum number of attempts
-
maxConnectAttemptsTipText
public String maxConnectAttemptsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getReconnectWait
public int getReconnectWait()
Returns the number of seconds to wait before trying to reconnect.- Returns:
- the number of seconds
-
setReconnectWait
public void setReconnectWait(int value)
Sets the number of seconds to wait before trying to reconnect.- Parameters:
value
- the number of seconds
-
getDefaultReconnectWait
public int getDefaultReconnectWait()
Returns the number of seconds to wait before trying to reconnect.- Returns:
- the default number of seconds
-
reconnectWaitTipText
public String reconnectWaitTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getDefaultConnectOnStartUp
public boolean getDefaultConnectOnStartUp()
Returns whether to automatically connect on startup, i.e., when obtaining the singleton for the first time.- Returns:
- true if to connect automatically on startup
-
setDefaultConnectOnStartUp
public void setDefaultConnectOnStartUp(boolean value)
Sets the default for whether to connect on startup.- Parameters:
value
- the default
-
getConnectOnStartUp
public boolean getConnectOnStartUp()
Returns whether to use connect on start-up.- Returns:
- true if connecting on startup
-
setConnectOnStartUp
public void setConnectOnStartUp(boolean value)
Sets whether to connect on start-up (only if not connected).- Parameters:
value
- true if to connect on startup
-
connectOnStartUpTipText
public String connectOnStartUpTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getDefaultAutoCommit
public boolean getDefaultAutoCommit()
Returns whether to use auto-commit.- Returns:
- true if to use auto-commit
-
setDefaultAutoCommit
public void setDefaultAutoCommit(boolean value)
Sets the default for auto-commit.- Parameters:
value
- the default
-
getAutoCommit
public boolean getAutoCommit()
Returns whether to use auto-commit.- Returns:
- true if to use auto-commit
-
setAutoCommit
public void setAutoCommit(boolean value)
Sets whether to use auto-commit.- Parameters:
value
- true if to use auto-commit
-
autoCommitTipText
public String autoCommitTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getCurrentConnectionParameters
public ConnectionParameters getCurrentConnectionParameters()
Returns the current connection parameters.- Returns:
- the parameters
-
toConnectionParameters
public ConnectionParameters toConnectionParameters(AbstractDatabaseConnection conn)
Turns the database connection into a parameters object.- Parameters:
conn
- the connection to convert- Returns:
- the parameters
-
getFailedConnectAttemptKey
protected String getFailedConnectAttemptKey(String url, String user, BasePassword password)
Generates a key for the failed connect attempt hashtable.- Parameters:
url
- the JDBC URLuser
- the database userpassword
- the database password- Returns:
- the generated key for the hashtable
-
getFailedConnectAttempt
protected int getFailedConnectAttempt(String url, String user, BasePassword password)
Returns the failed attempt count for the given connection.- Parameters:
url
- the JDBC URLuser
- the database userpassword
- the database password- Returns:
- the current count
-
incFailedConnectAttempt
protected void incFailedConnectAttempt(String url, String user, BasePassword password)
Increments the failed attempt for the given connection.- Parameters:
url
- the JDBC URLuser
- the database userpassword
- the database password
-
resetFailedConnectAttempt
public void resetFailedConnectAttempt()
Resets the failed attempts for the current connection.
-
resetFailedConnectAttempt
protected void resetFailedConnectAttempt(String url, String user, BasePassword password)
Resets the failed attempt for the given connection.- Parameters:
url
- the JDBC URLuser
- the database userpassword
- the database password
-
getLastConnectionError
public String getLastConnectionError()
Returns the last error that happened when connecting to the database.- Returns:
- the last error, "" if non occurred
-
getConnection
public Connection getConnection(boolean keepTrying)
Return db connection.- Parameters:
keepTrying
- continue attempting to connect- Returns:
- new Connection
-
tryConnection
protected boolean tryConnection()
Tries to reconnect.- Returns:
- true if successful
-
isConnectionOK
public boolean isConnectionOK()
Returns if connection to database is OK.- Returns:
- true if connection OK
-
isConnected
public boolean isConnected()
Is database connected?- Returns:
- database connected?
-
retryConnect
public boolean retryConnect()
Redo connection to database.- Returns:
- success?
-
connect
public boolean connect() throws Exception
Try to make a connection to the database, with the url,username and password.- Returns:
- connect OK
- Throws:
Exception
- if connection cannot be instantiated
-
disconnect
public boolean disconnect()
Attempt disconnect from db.- Returns:
- success?
-
newConnectionParameters
public ConnectionParameters newConnectionParameters()
Returns a new instance of a ConnectionParameters object.- Returns:
- the new instance
-
getDefaultConnectionParameters
public ConnectionParameters getDefaultConnectionParameters()
Returns the default connection parameter object.- Returns:
- the default
-
getAllConnectionParameters
public List<ConnectionParameters> getAllConnectionParameters()
Returns the stored connections.- Returns:
- the connections
-
connectionsToProperties
protected boolean connectionsToProperties(List<ConnectionParameters> connections)
Replaces the current connections with the provided ones and updates the .props file.- Parameters:
connections
- the connections to store- Returns:
- true if successfully updated
-
addConnectionParameters
public boolean addConnectionParameters(ConnectionParameters conn)
Adds the given connection to the props file.- Parameters:
conn
- the connection to add- Returns:
- true if successfully added
-
removeConnectionParameters
public boolean removeConnectionParameters(ConnectionParameters conn)
Removes the given connection from the props file.- Parameters:
conn
- the connection to remove- Returns:
- true if successfully removed
-
makeDefaultConnection
public boolean makeDefaultConnection(ConnectionParameters conn)
Sets the given connection as the default one.- Parameters:
conn
- the connection to use as default- Returns:
- true if successfully set as default
-
updateConnectionParameters
public boolean updateConnectionParameters()
Updates the props file in the project's home directory.- Returns:
- true if sucessfully updated
-
outputChangeListeners
protected void outputChangeListeners()
Outputs the change listeners if debugging is on.
-
addChangeListener
public void addChangeListener(DatabaseConnectionChangeListener l)
Adds a listener for connect/disconnect events to the internal list.- Parameters:
l
- the listener to add
-
removeChangeListener
public void removeChangeListener(DatabaseConnectionChangeListener l)
Removes a listener for connect/disconnect events from the internal list.- Parameters:
l
- the listener to remove
-
notifyChangeListeners
public void notifyChangeListeners(DatabaseConnectionChangeEvent e)
Notifies all listeners with the given event.- Parameters:
e
- the event to send to the listeners
-
compareTo
public int compareTo(AbstractDatabaseConnection 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. Uses the database URL and user for comparison.- Specified by:
compareTo
in interfaceComparable<AbstractDatabaseConnection>
- 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.
-
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. Uses the database URL and user for comparison.- 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 o)
Checks wether this object is the same as the provided one. Only uses the database URL for comparison.
-
hashCode
public int hashCode()
Hashcode so can be used as hashtable key. Returns the hashcode of the "url \t user" string.
-
getClone
public AbstractDatabaseConnection getClone()
Returns a clone of the object.- Specified by:
getClone
in interfaceCloneHandler<AbstractDatabaseConnection>
- Returns:
- the clone
-
toStringShort
public String toStringShort()
Returns a short string representation of the connection.- Returns:
- a short string representation
-
toString
public String toString()
Returns a string representation of the connection object.
-
toCommandLine
public String toCommandLine()
Returns the commandline string.- Specified by:
toCommandLine
in interfaceOptionHandler
- Returns:
- the commandline
-
-