Package xal.tools.database
Class ConnectionDictionary
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<Object,
Object>
ConnectionDictionary contains properties that can be used to establish a
database connection. It should contain at least the database URL, user name
and password. A default connection dictionary can be fetched from a file
specified in the user's preferences.
- Author:
- tap
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
Fields inherited from class java.util.Properties
defaults
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ConnectionDictionary
Get the connection dictionary from the file specified in the user's preferences.Get the database adaptor to usestatic ConnectionDictionary
Get the connection dictionary from the URL specified in the user's preferences.static ConnectionDictionary
getInstance
(String accountName) Get the connection dictionary from the URL specified in the user's preferences and for the specified account.static ConnectionDictionary
getInstance
(String accountName, String serverName) Get the connection dictionary from the URL specified in the user's preferences and for the specified account and server.Get the user password for connectingstatic ConnectionDictionary
getPreferredInstance
(String... accountNames) Get the available connection dictionary which is the most preferredGet the connection URLgetUser()
Get the user name for connectingboolean
Determine if the dictionary is sufficiently complete regardless whether the data is right or wrong.void
setDatabaseAdaptorClass
(Class<?> databaseAdaptorClass) Set the database adaptor classvoid
setDatabaseAdaptorClass
(String className) Set the database adaptor classvoid
setPassword
(String password) Set the passwordvoid
setURLSpec
(String urlSpec) Set the URL specvoid
Set the user IDMethods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, getProperty, getProperty, hashCode, isEmpty, keys, keySet, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, setProperty, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
Field Details
-
USER_KEY
- See Also:
-
PASSWORD_KEY
- See Also:
-
URL_KEY
- See Also:
-
DATABASE_ADAPTOR_KEY
- See Also:
-
-
Constructor Details
-
ConnectionDictionary
public ConnectionDictionary()Constructor
-
-
Method Details
-
defaultDictionary
Get the connection dictionary from the file specified in the user's preferences.- Returns:
- the user's default connection dictionary
-
getInstance
Get the connection dictionary from the URL specified in the user's preferences.- Returns:
- the user's default connection dictionary
-
getInstance
Get the connection dictionary from the URL specified in the user's preferences and for the specified account.- Parameters:
accountName
- name of the account for which to initialize the connection dictionary (or null to use the default account if any)- Returns:
- the user's default connection dictionary
-
getPreferredInstance
Get the available connection dictionary which is the most preferred- Parameters:
accountNames
- ordered (most preferred is first) accounts to search among
-
getInstance
Get the connection dictionary from the URL specified in the user's preferences and for the specified account and server.- Parameters:
accountName
- name of the account for which to initialize the connection dictionary (or null to use the default account if any)serverName
- name of the database server for which to initialize the connection dictionary (or null to use the default server if any)- Returns:
- the user's default connection dictionary
-
hasRequiredInfo
public boolean hasRequiredInfo()Determine if the dictionary is sufficiently complete regardless whether the data is right or wrong.- Returns:
- true if the dictionary contains the user name, password and database URL (database adaptor is optional)
-
getUser
Get the user name for connecting- Returns:
- the user name
-
setUser
Set the user ID- Parameters:
userID
- The user ID
-
getPassword
Get the user password for connecting- Returns:
- the user password
-
setPassword
Set the password- Parameters:
password
- the password
-
getURLSpec
Get the connection URL- Returns:
- the connection URL
-
setURLSpec
Set the URL spec- Parameters:
urlSpec
- The URL spec
-
getDatabaseAdaptor
Get the database adaptor to use- Returns:
- the database adaptor
-
setDatabaseAdaptorClass
Set the database adaptor class- Parameters:
databaseAdaptorClass
- the database adaptor class to use
-
setDatabaseAdaptorClass
Set the database adaptor class- Parameters:
className
- the database adaptor class name to use
-