DataBase.java 835 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
package com.roshka.proyectofinal;

import java.sql.Connection;
import java.sql.DriverManager;

public class DataBase {

    public static Connection getConnection(){
        Connection con=null;
        try{
            Class.forName("org.postgresql.Driver");
            con= DriverManager
13
                    .getConnection("jdbc:postgresql://localhost:5432/bootcamp_th",
14
                            "postgres", "2022roshka");
15 16 17 18 19 20 21 22 23 24 25 26 27 28

            if(con != null){
                System.out.println("---> CONNECTED TO SERVER");
            }else {
                System.out.println("---> UNABLE TO CONNECTED TO SERVER");
            }
        }catch(Exception e){
            e.printStackTrace();
            System.err.println(e.getClass().getName()+": "+e.getMessage());
            System.exit(0);
        }
        return con;
    }
}