com.atlassian.jira.config.database
Class JdbcDatasource.Builder

java.lang.Object
  extended by com.atlassian.jira.config.database.JdbcDatasource.Builder
Enclosing class:
JdbcDatasource

public static class JdbcDatasource.Builder
extends Object

This is a builder class for constructing a JdbcDatasource manually. Use the JdbcDatasource.builder() factory to obtain an instance of this class and call the various setXyzzy methods to populate the fields. Those that are left unset or are explicitly set to null will use their default values.


Constructor Summary
JdbcDatasource.Builder()
           
 
Method Summary
 JdbcDatasource build()
          Returns a new JdbcDatasource as specified by the current state of this builder.
 boolean equals(Object o)
           
 org.ofbiz.core.entity.config.ConnectionPoolInfo getConnectionPoolInfo()
           
 Properties getConnectionProperties()
           
 DatabaseType getDatabaseType()
           
 String getDriverClassName()
           
 String getHostname()
           
 String getInstance()
           
 String getJdbcUrl()
           
 String getPassword()
           
 String getPort()
           
 String getUsername()
           
 int hashCode()
           
 JdbcDatasource.Builder setConnectionPoolInfo(org.ofbiz.core.entity.config.ConnectionPoolInfo connectionPoolInfo)
           
 JdbcDatasource.Builder setConnectionProperties(Properties connectionProperties)
           
 JdbcDatasource.Builder setDatabaseType(DatabaseType databaseType)
          Sets the database type.
 JdbcDatasource.Builder setDriverClassName(String driverClassName)
          The driver class name is required when the JDBC URL is explicitly set.
 JdbcDatasource.Builder setHostname(String hostname)
          Sets the hostname for the JDBC URL.
 JdbcDatasource.Builder setInstance(String instance)
          Sets the instance for the JDBC URL.
 JdbcDatasource.Builder setJdbcUrl(String jdbcUrl)
          Sets an explicit value for the JDBC URL.
 JdbcDatasource.Builder setPassword(String password)
           
 JdbcDatasource.Builder setPort(String port)
          Sets the port for the JDBC URL.
 JdbcDatasource.Builder setUsername(String username)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JdbcDatasource.Builder

public JdbcDatasource.Builder()
Method Detail

build

public JdbcDatasource build()
Returns a new JdbcDatasource as specified by the current state of this builder.

Returns:
the new JdbcDatasource
Throws:
IllegalArgumentException - if the configuration is invalid, such as if the username is left unspecified or if neither the JDBC URL nor a database type is given.
InvalidDatabaseDriverException - if the database driver is invalid

getDatabaseType

public DatabaseType getDatabaseType()

setDatabaseType

public JdbcDatasource.Builder setDatabaseType(DatabaseType databaseType)
Sets the database type. This value, the hostname, the port, and the instance are ignored if the JDBC URL is explicitly set. One or the other means of setting the URL is required.

Parameters:
databaseType - the database type for the JDBC URL
Returns:
this builder
See Also:
setJdbcUrl(String)

getHostname

public String getHostname()

setHostname

public JdbcDatasource.Builder setHostname(String hostname)
Sets the hostname for the JDBC URL.

Parameters:
hostname - the hostname for the JDBC URL
Returns:
this builder
See Also:
setDatabaseType(DatabaseType), setJdbcUrl(String)

getPort

public String getPort()

setPort

public JdbcDatasource.Builder setPort(String port)
Sets the port for the JDBC URL.

Parameters:
port - the port for the JDBC URL
Returns:
this builder
See Also:
setDatabaseType(DatabaseType), setJdbcUrl(String)

getInstance

public String getInstance()

setInstance

public JdbcDatasource.Builder setInstance(String instance)
Sets the instance for the JDBC URL.

Parameters:
instance - the instance for the JDBC URL
Returns:
this builder
See Also:
setDatabaseType(DatabaseType), setJdbcUrl(String)

getJdbcUrl

public String getJdbcUrl()

setJdbcUrl

public JdbcDatasource.Builder setJdbcUrl(String jdbcUrl)
Sets an explicit value for the JDBC URL. If this value is not set, then the database type, hostname, port, and instance must be set, instead. If this is set, then those other values are ignored, and the driver class name will be required.

Parameters:
jdbcUrl - the complete JDBC URL to use
Returns:
this builder
See Also:
setDatabaseType(DatabaseType), setDriverClassName(String)

getDriverClassName

public String getDriverClassName()

setDriverClassName

public JdbcDatasource.Builder setDriverClassName(String driverClassName)
The driver class name is required when the JDBC URL is explicitly set. Otherwise, it is ignored.

Parameters:
driverClassName - the class name of the JDBC driver to use
Returns:
this builder

getUsername

public String getUsername()

setUsername

public JdbcDatasource.Builder setUsername(String username)

getPassword

public String getPassword()

setPassword

public JdbcDatasource.Builder setPassword(String password)

getConnectionProperties

public Properties getConnectionProperties()

setConnectionProperties

public JdbcDatasource.Builder setConnectionProperties(Properties connectionProperties)

getConnectionPoolInfo

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

setConnectionPoolInfo

public JdbcDatasource.Builder setConnectionPoolInfo(org.ofbiz.core.entity.config.ConnectionPoolInfo connectionPoolInfo)

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2002-2013 Atlassian. All Rights Reserved.