Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ConnectionFactory {
- private String url = "jdbc:postgresql://localhost/banco";
- private String usuario = "usuario_banco";
- private String senha = "senha_usuario";
- String driver = "org.postgresql.Driver";
- Connection conexao;
- /**
- * Metodo getConnection retorna uma conexao
- *
- * @return Connection que é uma conexao
- */
- public Connection getConnection() {
- try {
- try {
- Class.forName(driver);
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- conexao = DriverManager.getConnection(url, usuario, senha);
- return conexao;
- } catch (SQLException erro) {
- throw new RuntimeException(erro);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement