com.atlassian.jira.config.database
Class JdbcDatasource

java.lang.Object
  extended by com.atlassian.jira.config.database.JdbcDatasource
All Implemented Interfaces:
Datasource

public final class JdbcDatasource
extends Object
implements Datasource

A JDBC datasource. Note: The direct constructors for this class are all deprecated. Use the JdbcDatasource.Builder instead. Several getters are also deprecated because the same data can be obtained indirectly through getConnectionPoolInfo().


Nested Class Summary
static class JdbcDatasource.Builder
          This is a builder class for constructing a JdbcDatasource manually.
 
Constructor Summary
JdbcDatasource(DatabaseType databaseType, String hostname, String port, String instance, String username, String password, Integer poolMaxSize, String validationQuery, Long minEvictableTimeMillis, Long timeBetweenEvictionRunsMillis)
          Deprecated. 
JdbcDatasource(org.ofbiz.core.entity.config.JdbcDatasourceInfo jdbc)
           
JdbcDatasource(String jdbcUrl, String driverClassName, String username, String password, int poolMaxSize, String validationQuery, Long minEvictableTimeMillis, Long timeBetweenEvictionRunsMillis)
          Deprecated. 
JdbcDatasource(String jdbcUrl, String driverClassName, String username, String password, Properties connectionProperties, int poolMaxSize, String validationQuery, Long minEvictableTimeMillis, Long timeBetweenEvictionRunsMillis)
          Deprecated. 
 
Method Summary
static JdbcDatasource.Builder builder()
          Factory method to create a new JdbcDatasource.Builder for constructing a JdbcDatasource using a chain of named setters rather than a long list of parameters in a specific order.
 boolean equals(Object o)
           
 Connection getConnection(com.atlassian.config.bootstrap.AtlassianBootstrapManager bootstrapManager)
          Uses the given link AtlassianBootstrapManager to acquire a Connection to the database defined by this Datasource.
 org.ofbiz.core.entity.config.ConnectionPoolInfo getConnectionPoolInfo()
           
 Properties getConnectionProperties()
           
 org.ofbiz.core.entity.config.DatasourceInfo getDatasource(String datasourceName, String databaseType, String schemaName)
          Get the equivalent Ofbiz DatasourceInfo config class for this Datasource.
 String getDescriptorLabel()
          Provides the name of the datasource field that this datasource represents.
 String getDescriptorValue(String databaseType)
          Provides a text description suitable for an administrator that identifies the datasource.
 String getDriverClassName()
          The class name for the driver
 String getJdbcUrl()
          The JDBC URL
 Long getMinEvictableTimeMillis()
          Deprecated. 
 String getPassword()
          The password for the database connection
 int getPoolSize()
          Deprecated. 
 Long getTimeBetweenEvictionRunsMillis()
          Deprecated. 
 String getUsername()
          The username for the database connection
 String getValidationQuery()
          Deprecated. 
 int hashCode()
           
static void registerDriver(String className)
           
static void setRegisterDriverOnConstruct(boolean registerDriverOnConstruct)
          This setting is soley so the config tool can avoid the fatal side-effect of registering the JDBC driver in this class's constructor.
 JdbcDatasource.Builder toBuilder()
           
 String toString()
           
 void writeTo(org.dom4j.Element element)
          Serializes this JDBC to an XML element.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JdbcDatasource

@Deprecated
public JdbcDatasource(String jdbcUrl,
                                 String driverClassName,
                                 String username,
                                 String password,
                                 int poolMaxSize,
                                 String validationQuery,
                                 Long minEvictableTimeMillis,
                                 Long timeBetweenEvictionRunsMillis)
Deprecated. 


JdbcDatasource

@Deprecated
public JdbcDatasource(String jdbcUrl,
                                 String driverClassName,
                                 String username,
                                 String password,
                                 Properties connectionProperties,
                                 int poolMaxSize,
                                 String validationQuery,
                                 Long minEvictableTimeMillis,
                                 Long timeBetweenEvictionRunsMillis)
Deprecated. 


JdbcDatasource

@Deprecated
public JdbcDatasource(DatabaseType databaseType,
                                 String hostname,
                                 String port,
                                 String instance,
                                 String username,
                                 String password,
                                 Integer poolMaxSize,
                                 String validationQuery,
                                 Long minEvictableTimeMillis,
                                 Long timeBetweenEvictionRunsMillis)
Deprecated. 


JdbcDatasource

public JdbcDatasource(org.ofbiz.core.entity.config.JdbcDatasourceInfo jdbc)
Method Detail

setRegisterDriverOnConstruct

public static void setRegisterDriverOnConstruct(boolean registerDriverOnConstruct)
This setting is soley so the config tool can avoid the fatal side-effect of registering the JDBC driver in this class's constructor.

Parameters:
registerDriverOnConstruct - If true we do "Class.forName(driverClassName);" in the Constructor.

registerDriver

public static void registerDriver(String className)

builder

public static JdbcDatasource.Builder builder()
Factory method to create a new JdbcDatasource.Builder for constructing a JdbcDatasource using a chain of named setters rather than a long list of parameters in a specific order.

Returns:
a new JdbcDatasource.Builder

toBuilder

public JdbcDatasource.Builder toBuilder()

getConnection

public Connection getConnection(com.atlassian.config.bootstrap.AtlassianBootstrapManager bootstrapManager)
                         throws com.atlassian.config.bootstrap.BootstrapException
Description copied from interface: Datasource
Uses the given link AtlassianBootstrapManager to acquire a Connection to the database defined by this Datasource.

Specified by:
getConnection in interface Datasource
Parameters:
bootstrapManager - the bootstrapManager to use to get the connection.
Returns:
the connection.
Throws:
com.atlassian.config.bootstrap.BootstrapException - if the connection cannot be established.

getDatasource

public org.ofbiz.core.entity.config.DatasourceInfo getDatasource(String datasourceName,
                                                                 String databaseType,
                                                                 String schemaName)
Description copied from interface: Datasource
Get the equivalent Ofbiz DatasourceInfo config class for this Datasource. This effectively translates between this datasource and the ofbiz entityengine.xml of yore.

Specified by:
getDatasource in interface Datasource
Parameters:
datasourceName - the ofbiz name of the datasource.
databaseType - the field-type for the datasource as defined in ofbiz field-types.xml
schemaName - the name of the schema for the database (may be empty)
Returns:
an instance of a DatasourceInfo suitable for configuring Ofbiz.

getDescriptorValue

public String getDescriptorValue(String databaseType)
Description copied from interface: Datasource
Provides a text description suitable for an administrator that identifies the datasource.

Specified by:
getDescriptorValue in interface Datasource
Parameters:
databaseType - the field-type for the datasource as defined in ofbiz field-types.xml
Returns:
the description.

getDescriptorLabel

public String getDescriptorLabel()
Description copied from interface: Datasource
Provides the name of the datasource field that this datasource represents. Effectively, it delegates the name of the datasource field when the configuration is being described to an administrator and will say "JDBC Config" or "JNDI Name" as appropriate.

Specified by:
getDescriptorLabel in interface Datasource
Returns:
the label.

getJdbcUrl

public String getJdbcUrl()
The JDBC URL

Returns:
The JDBC URL

getDriverClassName

public String getDriverClassName()
The class name for the driver

Returns:
The class name. May or may not be valid.

getUsername

public String getUsername()
The username for the database connection

Returns:
The username

getPassword

public String getPassword()
The password for the database connection

Returns:
The password

getConnectionProperties

public Properties getConnectionProperties()

getConnectionPoolInfo

public org.ofbiz.core.entity.config.ConnectionPoolInfo getConnectionPoolInfo()

getPoolSize

@Deprecated
public int getPoolSize()
Deprecated. 


getValidationQuery

@Deprecated
public String getValidationQuery()
Deprecated. 


getMinEvictableTimeMillis

@Deprecated
public Long getMinEvictableTimeMillis()
Deprecated. 


getTimeBetweenEvictionRunsMillis

@Deprecated
public Long getTimeBetweenEvictionRunsMillis()
Deprecated. 


toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

writeTo

public void writeTo(org.dom4j.Element element)
Serializes this JDBC to an XML element. This creates a child element called jdbc-datasource which contains the settings.

Parameters:
element - the parent element within which to write the JDBC Datasource.


Copyright © 2002-2014 Atlassian. All Rights Reserved.