Created
May 29, 2014 16:29
-
-
Save rcaneppele/4b0e117754ad94aa1c97 to your computer and use it in GitHub Desktop.
FJ21-Tarefas - Multiplos Datasources
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
@Repository | |
public class JdbcTarefaDao | |
private Connection connection; | |
@Autowired | |
@Qualifier("postgreDataSource") | |
private DataSource dataSource; | |
@PostConstruct | |
public void init() { | |
try { | |
this.connection = dataSource.getConnection(); | |
} catch (SQLException e) { | |
throw new RuntimeException(e); | |
} | |
} | |
//métodos | |
} |
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
<bean id="mysqlDataSource" class="org.apache.commons.dbcp.BasicDataSource"> | |
<property name="driverClassName" value="com.mysql.jdbc.Driver"/> | |
<property name="url" value="jdbc:mysql://localhost/fj21"/> | |
<property name="username" value="root"/> | |
<property name="password" value=""/> | |
</bean> | |
<bean id="postgreDataSource" class="org.apache.commons.dbcp.BasicDataSource"> | |
<property name="driverClassName" value="org.postgresql.Driver"/> | |
<property name="url" value="jdbc:postgresql://localhost/fj21"/> | |
<property name="username" value="postgres"/> | |
<property name="password" value="postgres"/> | |
</bean> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment