Class ConnectionDictionary

All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>

public class ConnectionDictionary extends Properties
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 Details

  • Constructor Details

    • ConnectionDictionary

      public ConnectionDictionary()
      Constructor
  • Method Details

    • defaultDictionary

      public static ConnectionDictionary defaultDictionary()
      Get the connection dictionary from the file specified in the user's preferences.
      Returns:
      the user's default connection dictionary
    • getInstance

      public static ConnectionDictionary getInstance()
      Get the connection dictionary from the URL specified in the user's preferences.
      Returns:
      the user's default connection dictionary
    • getInstance

      public static ConnectionDictionary getInstance(String accountName)
      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

      public static ConnectionDictionary getPreferredInstance(String... accountNames)
      Get the available connection dictionary which is the most preferred
      Parameters:
      accountNames - ordered (most preferred is first) accounts to search among
    • getInstance

      public 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.
      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

      public String getUser()
      Get the user name for connecting
      Returns:
      the user name
    • setUser

      public void setUser(String userID)
      Set the user ID
      Parameters:
      userID - The user ID
    • getPassword

      public String getPassword()
      Get the user password for connecting
      Returns:
      the user password
    • setPassword

      public void setPassword(String password)
      Set the password
      Parameters:
      password - the password
    • getURLSpec

      public String getURLSpec()
      Get the connection URL
      Returns:
      the connection URL
    • setURLSpec

      public void setURLSpec(String urlSpec)
      Set the URL spec
      Parameters:
      urlSpec - The URL spec
    • getDatabaseAdaptor

      public DatabaseAdaptor getDatabaseAdaptor()
      Get the database adaptor to use
      Returns:
      the database adaptor
    • setDatabaseAdaptorClass

      public void setDatabaseAdaptorClass(Class<?> databaseAdaptorClass)
      Set the database adaptor class
      Parameters:
      databaseAdaptorClass - the database adaptor class to use
    • setDatabaseAdaptorClass

      public void setDatabaseAdaptorClass(String className)
      Set the database adaptor class
      Parameters:
      className - the database adaptor class name to use