Java Code Examples for org.springframework.boot.jdbc.DataSourceBuilder#url()

The following examples show how to use org.springframework.boot.jdbc.DataSourceBuilder#url() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlServerDataSourceCreateListener.java    From multitenant with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Organization organization, DataSourceInfo dataSourceInfo,
					 DataSourceBuilder<?> dataSourceBuilder) {

	if ("com.microsoft.sqlserver.jdbc.SQLServerDriver".equals(dataSourceInfo.getDriverClassName())) {
		String url = dataSourceInfo.getUrl();
		if (!url.contains(databaseNameService.getDatabaseName(Constants.MASTER))) {
			String databaseName = databaseNameService.getDatabaseName(Constants.MASTER);
			url += "/" + databaseName;
			dataSourceBuilder.url(url);
		}
	}
}
 
Example 2
Source File: MysqlDataSourceCreateListener.java    From multitenant with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Organization organization, DataSourceInfo dataSourceInfo,
					 DataSourceBuilder<?> dataSourceBuilder) {
	if ("com.mysql.jdbc.Driver".equals(dataSourceInfo.getDriverClassName())) {
		String url = dataSourceInfo.getUrl();
		if (!url.contains(databaseNameService.getDatabaseName(Constants.MASTER))) {
			String databaseName = databaseNameService.getDatabaseName(Constants.MASTER);
			url += "/" + databaseName;
			dataSourceBuilder.url(url);
		}
	}
	
}
 
Example 3
Source File: DataSourceBean.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public DataSource getDataSource() {
    DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
    dataSourceBuilder.driverClassName("org.h2.Driver");
    dataSourceBuilder.url("jdbc:h2:mem:test");
    dataSourceBuilder.username("SA");
    dataSourceBuilder.password("");
    return dataSourceBuilder.build();
}
 
Example 4
Source File: DataSourceConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public DataSource getDataSource() {
    DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
    dataSourceBuilder.driverClassName("org.h2.Driver");
    dataSourceBuilder.url("jdbc:h2:mem:test");
    dataSourceBuilder.username("SA");
    dataSourceBuilder.password("");
    return dataSourceBuilder.build();
}