org.appng.core.domain

## Class DatabaseConnection

- java.lang.Object
- - org.appng.core.domain.DatabaseConnection

- All Implemented Interfaces:
    Serializable, Identifiable<Integer>, Nameable, Named<Integer>, Versionable<Date>, Auditable<Integer>

      @Entity
      public class DatabaseConnection
      extends Object
      implements Auditable<Integer>

  Represents a connection to a database which is being used either by the platform itself ("root-connection") or by a `SiteApplication`.
  Author:
    Matthias Müller
  See Also:
    `SiteApplication.getDatabaseConnection()`, Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DatabaseConnection.DatabaseType` enum-type for the supported databases

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DB_PLACEHOLDER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DatabaseConnection()`
    `DatabaseConnection(DatabaseConnection.DatabaseType type, String databaseName, String userName, byte[] password)`
    `DatabaseConnection(DatabaseConnection.DatabaseType type, String jdbcUrl, String driverClass, String userName, byte[] password, String validationQuery)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `closeConnection(Connection connection)`
    `Connection` | `getConnection()`
    `String` | `getDatabaseConnectionString(String databaseName)`
    `String` | `getDatabaseName()`
    `Double` | `getDatabaseSize()`
    `DataSource` | `getDataSource()`
    `String` | `getDescription()` Returns the description.
    `@NotNull(message="{validation.notNull}") String` | `getDriverClass()`
    `Integer` | `getId()` Returns the id.
    `@NotNull(message="{validation.notNull}") String` | `getJdbcUrl()`
    `@NotNull(message="{validation.notNull}") Integer` | `getMaxConnections()`
    `org.flywaydb.core.api.MigrationInfoService` | `getMigrationInfoService()`
    `@NotNull(message="{validation.notNull}") @Min(value=1L,message="{validation.min}") Integer` | `getMinConnections()`
    `@NotNull(message="{validation.notNull}") String` | `getName()` Returns the name.
    `byte[]` | `getPassword()`
    `String` | `getPasswordPlain()`
    `String` | `getProductName()`
    `String` | `getProductVersion()`
    `Site` | `getSite()`
    `@NotNull(message="{validation.notNull}") DatabaseConnection.DatabaseType` | `getType()`
    `@NotNull(message="{validation.notNull}") String` | `getUserName()`
    `Integer` | `getValidationPeriod()`
    `String` | `getValidationQuery()`
    `Date` | `getVersion()` Returns the version.
    `boolean` | `isActive()`
    `boolean` | `isManaged()`
    `boolean` | `isRootConnection()`
    `void` | `registerDriver(boolean throwException)`
    `void` | `setActive(boolean active)`
    `void` | `setDatabaseSize(Double databaseSize)`
    `void` | `setDescription(String description)`
    `void` | `setDriverClass(String driverClass)`
    `void` | `setId(Integer id)`
    `void` | `setJdbcUrl(String jdbcUrl)`
    `void` | `setManaged(boolean managed)`
    `void` | `setMaxConnections(Integer maxConnections)`
    `void` | `setMigrationInfoService(org.flywaydb.core.api.MigrationInfoService migrationInfoService)`
    `void` | `setMinConnections(Integer minConnections)`
    `void` | `setName(String name)`
    `void` | `setPassword(byte[] password)`
    `void` | `setPasswordPlain(String passwordPlain)`
    `void` | `setSite(Site site)`
    `void` | `setType(DatabaseConnection.DatabaseType type)`
    `void` | `setUserName(String userName)`
    `void` | `setValidationPeriod(Integer validationPeriod)`
    `void` | `setValidationQuery(String validationQuery)`
    `void` | `setVersion(Date version)`
    `boolean` | `testConnection(boolean determineSize, org.springframework.jdbc.core.ConnectionCallback<?>... callbacks)`
    `boolean` | `testConnection(StringBuilder dbInfo)`
    `boolean` | `testConnection(StringBuilder dbInfo, boolean determineSize)`
    `String` | `toString()`

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

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

    - ### Methods inherited from interface org.appng.core.domain.Auditable

      `getAuditName`

- - ### Field Detail

    - #### DB_PLACEHOLDER

          public static final String DB_PLACEHOLDER

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### DatabaseConnection

          public DatabaseConnection()

    - #### DatabaseConnection

          public DatabaseConnection(DatabaseConnection.DatabaseType type,
                                    String databaseName,
                                    String userName,
                                    byte[] password)

    - #### DatabaseConnection

          public DatabaseConnection(DatabaseConnection.DatabaseType type,
                                    String jdbcUrl,
                                    String driverClass,
                                    String userName,
                                    byte[] password,
                                    String validationQuery)

  - ### Method Detail

    - #### getId

          public Integer getId()

      Description copied from interface: `Identifiable`
      Returns the id.
      Specified by:
        `getId` in interface `Identifiable<Integer>`
      Returns:
        the id

    - #### setId

          public void setId(Integer id)

    - #### getType

          @NotNull(message="{validation.notNull}")
          public @NotNull(message="{validation.notNull}") DatabaseConnection.DatabaseType getType()

    - #### setType

          public void setType(DatabaseConnection.DatabaseType type)

    - #### getName

          @NotNull(message="{validation.notNull}")
          public @NotNull(message="{validation.notNull}") String getName()

      Description copied from interface: `Nameable`
      Returns the name.
      Specified by:
        `getName` in interface `Nameable`
      Returns:
        the name

    - #### setName

          public void setName(String name)

    - #### getJdbcUrl

          @NotNull(message="{validation.notNull}")
          public @NotNull(message="{validation.notNull}") String getJdbcUrl()

    - #### setJdbcUrl

          public void setJdbcUrl(String jdbcUrl)

    - #### getUserName

          @NotNull(message="{validation.notNull}")
          public @NotNull(message="{validation.notNull}") String getUserName()

    - #### setUserName

          public void setUserName(String userName)

    - #### getPassword

          public byte[] getPassword()

    - #### setPassword

          public void setPassword(byte[] password)

    - #### getDriverClass

          @NotNull(message="{validation.notNull}")
          public @NotNull(message="{validation.notNull}") String getDriverClass()

    - #### setDriverClass

          public void setDriverClass(String driverClass)

    - #### getVersion

          public Date getVersion()

      Description copied from interface: `Versionable`
      Returns the version.
      Specified by:
        `getVersion` in interface `Versionable<Date>`
      Returns:
        the version

    - #### setVersion

          public void setVersion(Date version)

    - #### getDescription

          public String getDescription()

      Description copied from interface: `Nameable`
      Returns the description.
      Specified by:
        `getDescription` in interface `Nameable`
      Returns:
        the description

    - #### setDescription

          public void setDescription(String description)

    - #### getSite

          public Site getSite()

    - #### setSite

          public void setSite(Site site)

    - #### isActive

          public boolean isActive()

    - #### setActive

          public void setActive(boolean active)

    - #### getMinConnections

          @NotNull(message="{validation.notNull}")
           @Min(value=1L,
               message="{validation.min}")
          public @NotNull(message="{validation.notNull}") @Min(value=1L,message="{validation.min}") Integer getMinConnections()

    - #### setMinConnections

          public void setMinConnections(Integer minConnections)

    - #### getMaxConnections

          @NotNull(message="{validation.notNull}")
          public @NotNull(message="{validation.notNull}") Integer getMaxConnections()

    - #### setMaxConnections

          public void setMaxConnections(Integer maxConnections)

    - #### isManaged

          public boolean isManaged()

    - #### setManaged

          public void setManaged(boolean managed)

    - #### getValidationQuery

          public String getValidationQuery()

    - #### setValidationQuery

          public void setValidationQuery(String validationQuery)

    - #### getPasswordPlain

          public String getPasswordPlain()

    - #### setPasswordPlain

          public void setPasswordPlain(String passwordPlain)

    - #### getValidationPeriod

          public Integer getValidationPeriod()

    - #### setValidationPeriod

          public void setValidationPeriod(Integer validationPeriod)

    - #### registerDriver

          public void registerDriver(boolean throwException)

    - #### testConnection

          public boolean testConnection(StringBuilder dbInfo)

    - #### testConnection

          public boolean testConnection(StringBuilder dbInfo,
                                        boolean determineSize)

    - #### testConnection

          public boolean testConnection(boolean determineSize,
                                        org.springframework.jdbc.core.ConnectionCallback<?>... callbacks)

    - #### getConnection

          public Connection getConnection()
                                   throws SQLException

      Throws:
        `SQLException`

    - #### closeConnection

          public void closeConnection(Connection connection)

    - #### getDatabaseConnectionString

          public String getDatabaseConnectionString(String databaseName)

    - #### getDatabaseName

          public String getDatabaseName()

    - #### isRootConnection

          public boolean isRootConnection()

    - #### getMigrationInfoService

          public org.flywaydb.core.api.MigrationInfoService getMigrationInfoService()

    - #### setMigrationInfoService

          public void setMigrationInfoService(org.flywaydb.core.api.MigrationInfoService migrationInfoService)

    - #### getDatabaseSize

          public Double getDatabaseSize()

    - #### setDatabaseSize

          public void setDatabaseSize(Double databaseSize)

    - #### getProductName

          public String getProductName()

    - #### getProductVersion

          public String getProductVersion()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getDataSource

          public DataSource getDataSource()

Copyright © 2011–2023 aiticon GmbH. All rights reserved.