Last active
January 8, 2016 22:15
-
-
Save theflofly/891469780810a867c351 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.tcb.issue1.configuration; | |
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; | |
import org.springframework.beans.factory.annotation.Value; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.transaction.annotation.EnableTransactionManagement; | |
import javax.sql.DataSource; | |
import java.sql.SQLException; | |
/** | |
* This class is the configuration class for the MySQL datasource. | |
* | |
* @author [email protected] | |
*/ | |
@Configuration | |
public class MySQLConfiguration { | |
@Value("${mysql.password}") | |
private String password; | |
@Value("${mysql.user}") | |
private String user; | |
@Value("${mysql.host}") | |
private String dbHost; | |
@Value("${mysql.port}") | |
private String dbPort; | |
@Value("${mysql.dbName}") | |
private String dbName; | |
/** | |
* Creation of a MysqlDataSource instance according to properties extracted from the configuration file. | |
* | |
* @return a DataSource instance initialized according to the properties file. | |
* @throws java.sql.SQLException | |
*/ | |
@Bean | |
public DataSource provisioningDbDataSource() throws SQLException { | |
MysqlDataSource provisioningDbDataSource = new MysqlDataSource(); | |
provisioningDbDataSource.setURL("jdbc:mysql://" + dbHost + ":" + dbPort +"/" + dbName); | |
provisioningDbDataSource.setUser(user); | |
provisioningDbDataSource.setPassword(password); | |
return provisioningDbDataSource; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment