de.esprit.appsuite.database.dbase

## Class Credential

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.common.util.TransferableObject
    - - de.esprit.appsuite.database.dbase.Credential

- All Implemented Interfaces:
    Clearable, DeepCloneable, Dumpable, java.io.Serializable, java.lang.Cloneable
  Direct Known Subclasses:
    AbstractDBOCredential, CredentialDB2, CredentialDB2J, CredentialDerby, CredentialInformix, CredentialMySQL, CredentialOracle, CredentialOracle9, CredentialPointBase, ServerCredential

      public class Credential
      extends TransferableObject
      implements Clearable

  This class encapsulates the parameters that are necessary to connect to a database via JDBC.
  Author:
    Rainer Buesch
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String` | `connUrl`
    `static java.lang.String` | `connUrlKey`
    `static java.lang.String` | `credentialDocType`
    `protected java.lang.String` | `dbPassword`
    `static java.lang.String` | `dbPasswordKey`
    `protected java.lang.String` | `dbSchema`
    `static java.lang.String` | `dbSchemaKey`
    `protected java.lang.String` | `dbUser`
    `static java.lang.String` | `dbUserKey`
    `static java.lang.String` | `DEFAULT_DATABASE_PATH`
    `static java.lang.String` | `DERBY_SYSTEM_HOME`
    `protected java.lang.String` | `jdbcDriver`
    `static java.lang.String` | `jdbcDriverKey`
    `protected int` | `loginTimeout`
    `static java.lang.String` | `loginTimeoutKey`
    `protected int` | `maxConns`
    `static java.lang.String` | `maxConnsKey`
    `protected int` | `minConns`
    `static java.lang.String` | `minConnsKey`
    `static java.lang.String` | `systemPropsType`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Credential()`
    `Credential(DatabaseCommandLineParser clp)` Builds the credential by reading the following parameters from the command line: -driver JDBC driver className -dbUrl Database connection url -user Database login user -password database login password -schema The database schema to be used -minConns Minimum number of pool connections (default 1) -maxConns Maximum number of pool connections (default 1) -loginTimeout Max seconds to wait for a database login
    `Credential(java.lang.String jdbcDriver, java.lang.String connUrl, java.lang.String dbUser, java.lang.String dbPassword)`
    `Credential(java.lang.String jdbcDriver, java.lang.String connUrl, java.lang.String dbUser, java.lang.String dbPassword, java.lang.String dbSchema)`
    `Credential(java.lang.String jdbcDriver, java.lang.String connUrl, java.lang.String dbUser, java.lang.String dbPassword, java.lang.String dbSchema, int minConns, int maxConns, int loginTimeout)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Clears the content
    `java.lang.String` | `getConnectionUrl()`
    `java.io.File` | `getCredFile()`
    `java.lang.String` | `getDatabaseName()` Tries to figure out the database name from the connection URL
    `java.util.Map<java.lang.String,java.lang.String>` | `getDefaultSystemProperties()`
    `java.lang.String` | `getDefaultSystemProperty(java.lang.String propertyKey)` Note: if the property was already passed by VM option (-Dkey=value) the VM option always precedes!
    `java.lang.String` | `getJdbcDriver()`
    `int` | `getLoginTimeout()`
    `int` | `getMaxConns()`
    `int` | `getMinConns()`
    `java.lang.String` | `getPassword()`
    `java.lang.String` | `getSchema()`
    `java.lang.String` | `getUser()`
    `void` | `initDefaultSystemProperties()` This method is called just before a database connection is established.
    `boolean` | `isValid()`
    `void` | `putDefaultSystemProperty(java.lang.String key, java.lang.String value)` Defines a default value for a system property (i.e. derby.system.home).
    `void` | `read(ApplicationContext ctx, java.io.File inputFile)`
    `protected void` | `readCommandLineParams(DatabaseCommandLineParser clp)`
    `void` | `setConnectionUrl(java.lang.String url)`
    `void` | `setCredFile(java.io.File file)`
    `void` | `setJdbcDriver(java.lang.String driver)`
    `void` | `setLoginTimeout(int seconds)`
    `void` | `setMaxConns(int maxConns)`
    `void` | `setMinConns(int minConns)`
    `void` | `setPassword(java.lang.String passwd)`
    `void` | `setSchema(java.lang.String dbSchema)`
    `void` | `setUser(java.lang.String user)`
    `void` | `setValues(Credential cred)` Copies the values from the given credential object to this object
    `DumpString` | `toDumpString(DumpString s)` This method allows subclasses to add values to the existing DumpString of the superclass.
    `ToString` | `toString(ToString s)` This method allows subclasses to add values to the existing ToString of the superclass.
    `void` | `validate()`
    `void` | `write(ApplicationContext ctx, java.io.File outputFile)`

    - ### Methods inherited from class de.esprit.common.util.TransferableObject

      `clone, deepClone`

    - ### Methods inherited from class de.esprit.common.util.DumpableObject

      `configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toString`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### credentialDocType

          public static final java.lang.String credentialDocType

      See Also:
        Constant Field Values

    - #### systemPropsType

          public static final java.lang.String systemPropsType

      See Also:
        Constant Field Values

    - #### jdbcDriverKey

          public static final java.lang.String jdbcDriverKey

      See Also:
        Constant Field Values

    - #### connUrlKey

          public static final java.lang.String connUrlKey

      See Also:
        Constant Field Values

    - #### dbUserKey

          public static final java.lang.String dbUserKey

      See Also:
        Constant Field Values

    - #### dbPasswordKey

          public static final java.lang.String dbPasswordKey

      See Also:
        Constant Field Values

    - #### dbSchemaKey

          public static final java.lang.String dbSchemaKey

      See Also:
        Constant Field Values

    - #### minConnsKey

          public static final java.lang.String minConnsKey

      See Also:
        Constant Field Values

    - #### maxConnsKey

          public static final java.lang.String maxConnsKey

      See Also:
        Constant Field Values

    - #### loginTimeoutKey

          public static final java.lang.String loginTimeoutKey

      See Also:
        Constant Field Values

    - #### DERBY_SYSTEM_HOME

          public static final java.lang.String DERBY_SYSTEM_HOME

      See Also:
        Constant Field Values

    - #### DEFAULT_DATABASE_PATH

          public static final java.lang.String DEFAULT_DATABASE_PATH

      See Also:
        Constant Field Values

    - #### jdbcDriver

          protected java.lang.String jdbcDriver

    - #### connUrl

          protected java.lang.String connUrl

    - #### dbUser

          protected java.lang.String dbUser

    - #### dbPassword

          protected java.lang.String dbPassword

    - #### dbSchema

          protected java.lang.String dbSchema

    - #### minConns

          protected int minConns

    - #### maxConns

          protected int maxConns

    - #### loginTimeout

          protected int loginTimeout

  - ### Constructor Detail

    - #### Credential

          public Credential()

    - #### Credential

          public Credential(java.lang.String jdbcDriver,
                    java.lang.String connUrl,
                    java.lang.String dbUser,
                    java.lang.String dbPassword)

    - #### Credential

          public Credential(java.lang.String jdbcDriver,
                    java.lang.String connUrl,
                    java.lang.String dbUser,
                    java.lang.String dbPassword,
                    java.lang.String dbSchema)

    - #### Credential

          public Credential(java.lang.String jdbcDriver,
                    java.lang.String connUrl,
                    java.lang.String dbUser,
                    java.lang.String dbPassword,
                    java.lang.String dbSchema,
                    int minConns,
                    int maxConns,
                    int loginTimeout)

    - #### Credential

          public Credential(DatabaseCommandLineParser clp)
                     throws java.lang.Exception

      Builds the credential by reading the following parameters from the command line:
      - -driver
        JDBC driver className
      - -dbUrl
        Database connection url
      - -user
        Database login user
      - -password
        database login password
      - -schema
        The database schema to be used
      - -minConns
        Minimum number of pool connections (default 1)
      - -maxConns
        Maximum number of pool connections (default 1)
      - -loginTimeout
        Max seconds to wait for a database login
      Throws:
        `java.lang.Exception`

  - ### Method Detail

    - #### validate

          public void validate()

    - #### isValid

          public boolean isValid()

    - #### clear

          public void clear()

      Description copied from interface: `Clearable`
      Clears the content
      Specified by:
        `clear` in interface `Clearable`

    - #### getDefaultSystemProperties

          public java.util.Map<java.lang.String,java.lang.String> getDefaultSystemProperties()

    - #### putDefaultSystemProperty

          public void putDefaultSystemProperty(java.lang.String key,
                                      java.lang.String value)

      Defines a default value for a system property (i.e. derby.system.home). This value can be overridden by the VM option (-Dkey=value).

    - #### getDefaultSystemProperty

          public java.lang.String getDefaultSystemProperty(java.lang.String propertyKey)

      Note: if the property was already passed by VM option (-Dkey=value) the VM option always precedes!

    - #### readCommandLineParams

          protected void readCommandLineParams(DatabaseCommandLineParser clp)
                                        throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### setLoginTimeout

          public void setLoginTimeout(int seconds)

    - #### getLoginTimeout

          public int getLoginTimeout()

    - #### getUser

          public java.lang.String getUser()

    - #### getPassword

          public java.lang.String getPassword()

    - #### getSchema

          public java.lang.String getSchema()

    - #### getConnectionUrl

          public java.lang.String getConnectionUrl()

    - #### getJdbcDriver

          public java.lang.String getJdbcDriver()

    - #### getDatabaseName

          public java.lang.String getDatabaseName()

      Tries to figure out the database name from the connection URL

    - #### setUser

          public void setUser(java.lang.String user)

    - #### setPassword

          public void setPassword(java.lang.String passwd)

    - #### setConnectionUrl

          public void setConnectionUrl(java.lang.String url)

    - #### setJdbcDriver

          public void setJdbcDriver(java.lang.String driver)

    - #### setSchema

          public void setSchema(java.lang.String dbSchema)

    - #### getMaxConns

          public int getMaxConns()

    - #### setMaxConns

          public void setMaxConns(int maxConns)

    - #### getMinConns

          public int getMinConns()

    - #### setMinConns

          public void setMinConns(int minConns)

    - #### write

          public void write(ApplicationContext ctx,
                   java.io.File outputFile)
                     throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### read

          public void read(ApplicationContext ctx,
                  java.io.File inputFile)
                    throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### initDefaultSystemProperties

          public void initDefaultSystemProperties()

      This method is called just before a database connection is established. It activates the default system-properties defined in the credential. Note that a system-property set with the VM-option -Dkey=value always has precedence! Thus the credential provides defaults which will be overridden by a real system-property.

    - #### toString

          public ToString toString(ToString s)

      Description copied from interface: `Dumpable`
      This method allows subclasses to add values to the existing ToString of the superclass. Usually subclasses only need to override this method.
      Specified by:
        `toString` in interface `Dumpable`
      Overrides:
        `toString` in class `DumpableObject`

    - #### toDumpString

          public DumpString toDumpString(DumpString s)

      Description copied from interface: `Dumpable`
      This method allows subclasses to add values to the existing DumpString of the superclass. Usually subclasses only need to override this method.
      Specified by:
        `toDumpString` in interface `Dumpable`
      Overrides:
        `toDumpString` in class `DumpableObject`

    - #### getCredFile

          public java.io.File getCredFile()

    - #### setCredFile

          public void setCredFile(java.io.File file)

    - #### setValues

          public void setValues(Credential cred)

      Copies the values from the given credential object to this object

Copyright © 2014 EsprIT-Systems. All Rights Reserved.