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 Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class java.util.Properties
defaults -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ConnectionDictionaryGet the connection dictionary from the file specified in the user's preferences.Get the database adaptor to usestatic ConnectionDictionaryGet the connection dictionary from the URL specified in the user's preferences.static ConnectionDictionarygetInstance(String accountName) Get the connection dictionary from the URL specified in the user's preferences and for the specified account.static ConnectionDictionarygetInstance(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 ConnectionDictionarygetPreferredInstance(String... accountNames) Get the available connection dictionary which is the most preferredGet the connection URLgetUser()Get the user name for connectingbooleanDetermine if the dictionary is sufficiently complete regardless whether the data is right or wrong.voidsetDatabaseAdaptorClass(Class<?> databaseAdaptorClass) Set the database adaptor classvoidsetDatabaseAdaptorClass(String className) Set the database adaptor classvoidsetPassword(String password) Set the passwordvoidsetURLSpec(String urlSpec) Set the URL specvoidSet 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
-