Class BackendInfo


  • public class BackendInfo
    extends java.lang.Object
    Configuration info for a backend.
    Author:
    harald
    • Constructor Summary

      Constructors 
      Constructor Description
      BackendInfo​(java.lang.String backendName)
      Creates a backend info from a backend name.
      The info cannot be used to connect.
      BackendInfo​(java.lang.String url, java.lang.String user, char[] password, java.lang.String[] schemas)
      Creates a backend info.
      This info is able to create a connection.
      BackendInfo​(java.util.Properties backendProperties)
      Creates a backend info from backend properties.
      The info is able to create a connection.
      BackendInfo​(Backend backend)
      Creates a backend info from a backend.
      The info cannot be used to connect.
      BackendInfo​(BackendInfo backendInfo, java.lang.String user, char[] password)
      Creates a backend info from another one with a different user and password.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearPassword()
      Clears all passwords (stored in char[]-arrays) so that they are no more visible in memory.
      java.sql.Connection connect()
      Creates a connection.
      Backend getBackend()
      Gets the backend.
      javax.sql.DataSource getJndiDataSource()
      Gets the JNDI source.
      char[] getPassword()
      Gets the connection password.
      java.lang.String[] getSchemas()
      Gets the schemas.
      java.lang.String getUrl()
      Gets the connection url.
      java.lang.String getUser()
      Gets the username to connect.
      boolean isConnectable()
      Returns whether backend info can be used to connect.
      boolean isRemote()
      Returns whether this backend is remote.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • BackendInfo

        public BackendInfo​(Backend backend)
        Creates a backend info from a backend.
        The info cannot be used to connect.
        Parameters:
        backend - the backend
      • BackendInfo

        public BackendInfo​(java.lang.String backendName)
        Creates a backend info from a backend name.
        The info cannot be used to connect.
        Parameters:
        backendName - the backend name
      • BackendInfo

        public BackendInfo​(java.lang.String url,
                           java.lang.String user,
                           char[] password,
                           java.lang.String[] schemas)
        Creates a backend info.
        This info is able to create a connection.
        Parameters:
        url - the backend url
        user - the username
        password - the password
        schemas - the optional schemas, null if no schema check
      • BackendInfo

        public BackendInfo​(java.util.Properties backendProperties)
        Creates a backend info from backend properties.
        The info is able to create a connection.
        Parameters:
        backendProperties - the properties
      • BackendInfo

        public BackendInfo​(BackendInfo backendInfo,
                           java.lang.String user,
                           char[] password)
        Creates a backend info from another one with a different user and password.
        Parameters:
        backendInfo - the orginal backend info
        user - the username
        password - the password
    • Method Detail

      • getBackend

        public Backend getBackend()
        Gets the backend.
        Returns:
        the backend
      • isRemote

        public boolean isRemote()
        Returns whether this backend is remote.
        Returns:
        true if remote
      • getJndiDataSource

        public javax.sql.DataSource getJndiDataSource()
        Gets the JNDI source.
        Returns:
        the JNDI datasource if this a JNDI connection
      • getUrl

        public java.lang.String getUrl()
        Gets the connection url.
        Returns:
        the url, null if info cannot connect
      • getUser

        public java.lang.String getUser()
        Gets the username to connect.
        Returns:
        the username
      • getPassword

        public char[] getPassword()
        Gets the connection password.
        Returns:
        the password
      • clearPassword

        public void clearPassword()
        Clears all passwords (stored in char[]-arrays) so that they are no more visible in memory.
      • getSchemas

        public java.lang.String[] getSchemas()
        Gets the schemas.
        Returns:
        the schemas for migration
      • isConnectable

        public boolean isConnectable()
        Returns whether backend info can be used to connect.
        Returns:
        true if connectable
      • connect

        public java.sql.Connection connect()
                                    throws java.sql.SQLException
        Creates a connection.
        Returns:
        the connection in autocommit mode
        Throws:
        java.sql.SQLException - if connection could not be created
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object