Skip to content

Instantly share code, notes, and snippets.

View lubarinobr's full-sized avatar
🎯
Focusing

Matheus Lubarino lubarinobr

🎯
Focusing
  • Lisbon, Portugal
View GitHub Profile

Keybase proof

I hereby claim:

  • I am lubarinobr on github.
  • I am lubarino (https://keybase.io/lubarino) on keybase.
  • I have a public key ASBRT8ph2VoWvdFfbrCp9ZqCgC_ddKFgnXbyyF7PlHEedAo

To claim this, I am signing this object:

@lubarinobr
lubarinobr / factory.java
Created November 22, 2019 16:55
Custom facotry
public class Factory {
public getBean(Class theInterface) {
try {
Class clazz = Class.forName(theInterface.getName+"Impl");
return clazz.newInstance();
} catch (ReflectiveOperationException e) {
return null;
}
}
}
package br.com.lubarino.profiles.conexao;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
@Configuration
@Profile("qa")
public class BaseConfiguration {
spring.profiles.active=qa,stg
database.url: mysql-instance1-teste.rds.amazonaws.com
database.username: usuarioAmazon
database.password: senhaAmazon
package br.com.lubarino.profiles.conexao;
import org.springframework.beans.factory.annotation.Value;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class JDBCConnection {
database:
url: localhost
username: root
password: algumasenha
database.url=localhost
database.username=root
database.password=algumasenha
public Connection connect() throws ClassNotFoundException, SQLException {
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","username", "password");
return connection;
}