Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ConnectionFactory {
- private static final String DRIVER = "org.postgressql.Driver";
- private static final String URL = "jdbc:postgresql://localhost:5432/NomedoDB";
- private static final String USER = "postgres";
- private static final String PASS = "";
- public static Connection getConnection() throws SQLException {
- try {
- Class.forName(DRIVER);
- return DriverManager.getConnection(URL, USER, PASS);
- } catch (ClassNotFoundException ex) {
- throw new RuntimeException("Erro na conexão", ex);
- }
- }
- }
- public static void main(String[] args) throws SQLException {
- // TODO code application logic here
- ConnectionFactory conn = new ConnectionFactory();
- conn.getConnection();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement