Class DataSourceProperties
- java.lang.Object
- org.springframework.boot.autoconfigure.jdbc.DataSourceProperties
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanClassLoaderAware
,org.springframework.beans.factory.InitializingBean
@ConfigurationProperties(prefix="spring.datasource") public class DataSourceProperties extends Object implements org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.InitializingBean
Base class for configuration of a data source.- Since:
- 1.1.0
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DataSourceProperties.Xa
XA Specific datasource settings.
Constructor Summary
Constructors Constructor Description DataSourceProperties()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
String
determineDatabaseName()
Determine the name to used based on this configuration.String
determineDriverClassName()
Determine the driver to use based on this configuration and the environment.String
determinePassword()
Determine the password to use based on this configuration and the environment.String
determineUrl()
Determine the url to use based on this configuration and the environment.String
determineUsername()
Determine the username to use based on this configuration and the environment.ClassLoader
getClassLoader()
List<String>
getData()
String
getDataPassword()
String
getDataUsername()
String
getDriverClassName()
Return the configured driver ornull
if none was configured.org.springframework.boot.jdbc.DataSourceInitializationMode
getInitializationMode()
String
getJndiName()
String
getName()
String
getPassword()
Return the configured password ornull
if none was configured.String
getPlatform()
List<String>
getSchema()
String
getSchemaPassword()
String
getSchemaUsername()
String
getSeparator()
Charset
getSqlScriptEncoding()
Class<? extends DataSource>
getType()
String
getUrl()
Return the configured url ornull
if none was configured.String
getUsername()
Return the configured username ornull
if none was configured.DataSourceProperties.Xa
getXa()
org.springframework.boot.jdbc.DataSourceBuilder<?>
initializeDataSourceBuilder()
Initialize aDataSourceBuilder
with the state of this instance.boolean
isContinueOnError()
boolean
isGenerateUniqueName()
void
setBeanClassLoader(ClassLoader classLoader)
void
setContinueOnError(boolean continueOnError)
void
setData(List<String> data)
void
setDataPassword(String dataPassword)
void
setDataUsername(String dataUsername)
void
setDriverClassName(String driverClassName)
void
setGenerateUniqueName(boolean generateUniqueName)
void
setInitializationMode(org.springframework.boot.jdbc.DataSourceInitializationMode initializationMode)
void
setJndiName(String jndiName)
Allows the DataSource to be managed by the container and obtained via JNDI.void
setName(String name)
void
setPassword(String password)
void
setPlatform(String platform)
void
setSchema(List<String> schema)
void
setSchemaPassword(String schemaPassword)
void
setSchemaUsername(String schemaUsername)
void
setSeparator(String separator)
void
setSqlScriptEncoding(Charset sqlScriptEncoding)
void
setType(Class<? extends DataSource> type)
void
setUrl(String url)
void
setUsername(String username)
void
setXa(DataSourceProperties.Xa xa)
Constructor Detail
DataSourceProperties
public DataSourceProperties()
Method Detail
setBeanClassLoader
public void setBeanClassLoader(ClassLoader classLoader)
- Specified by:
setBeanClassLoader
in interfaceorg.springframework.beans.factory.BeanClassLoaderAware
afterPropertiesSet
public void afterPropertiesSet() throws Exception
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
initializeDataSourceBuilder
public org.springframework.boot.jdbc.DataSourceBuilder<?> initializeDataSourceBuilder()
Initialize aDataSourceBuilder
with the state of this instance.- Returns:
- a
DataSourceBuilder
initialized with the customizations defined on this instance
isGenerateUniqueName
public boolean isGenerateUniqueName()
setGenerateUniqueName
public void setGenerateUniqueName(boolean generateUniqueName)
getType
public Class<? extends DataSource> getType()
setType
public void setType(Class<? extends DataSource> type)
getDriverClassName
public String getDriverClassName()
Return the configured driver ornull
if none was configured.- Returns:
- the configured driver
- See Also:
determineDriverClassName()
setDriverClassName
public void setDriverClassName(String driverClassName)
determineDriverClassName
public String determineDriverClassName()
Determine the driver to use based on this configuration and the environment.- Returns:
- the driver to use
- Since:
- 1.4.0
getUrl
public String getUrl()
Return the configured url ornull
if none was configured.- Returns:
- the configured url
- See Also:
determineUrl()
determineUrl
public String determineUrl()
Determine the url to use based on this configuration and the environment.- Returns:
- the url to use
- Since:
- 1.4.0
determineDatabaseName
public String determineDatabaseName()
Determine the name to used based on this configuration.- Returns:
- the database name to use or
null
- Since:
- 2.0.0
getUsername
public String getUsername()
Return the configured username ornull
if none was configured.- Returns:
- the configured username
- See Also:
determineUsername()
setUsername
public void setUsername(String username)
determineUsername
public String determineUsername()
Determine the username to use based on this configuration and the environment.- Returns:
- the username to use
- Since:
- 1.4.0
getPassword
public String getPassword()
Return the configured password ornull
if none was configured.- Returns:
- the configured password
- See Also:
determinePassword()
setPassword
public void setPassword(String password)
determinePassword
public String determinePassword()
Determine the password to use based on this configuration and the environment.- Returns:
- the password to use
- Since:
- 1.4.0
getJndiName
public String getJndiName()
setJndiName
public void setJndiName(String jndiName)
Allows the DataSource to be managed by the container and obtained via JNDI. TheURL
,driverClassName
,username
andpassword
fields will be ignored when using JNDI lookups.- Parameters:
jndiName
- the JNDI name
getInitializationMode
public org.springframework.boot.jdbc.DataSourceInitializationMode getInitializationMode()
setInitializationMode
public void setInitializationMode(org.springframework.boot.jdbc.DataSourceInitializationMode initializationMode)
getPlatform
public String getPlatform()
setPlatform
public void setPlatform(String platform)
getSchemaUsername
public String getSchemaUsername()
setSchemaUsername
public void setSchemaUsername(String schemaUsername)
getSchemaPassword
public String getSchemaPassword()
setSchemaPassword
public void setSchemaPassword(String schemaPassword)
getDataUsername
public String getDataUsername()
setDataUsername
public void setDataUsername(String dataUsername)
getDataPassword
public String getDataPassword()
setDataPassword
public void setDataPassword(String dataPassword)
isContinueOnError
public boolean isContinueOnError()
setContinueOnError
public void setContinueOnError(boolean continueOnError)
getSeparator
public String getSeparator()
setSeparator
public void setSeparator(String separator)
getSqlScriptEncoding
public Charset getSqlScriptEncoding()
setSqlScriptEncoding
public void setSqlScriptEncoding(Charset sqlScriptEncoding)
getClassLoader
public ClassLoader getClassLoader()
getXa
public DataSourceProperties.Xa getXa()
setXa
public void setXa(DataSourceProperties.Xa xa)