diff --git a/src/main/java/com/roshka/proyectofinal/DataBase.java b/src/main/java/com/roshka/proyectofinal/DataBase.java new file mode 100644 index 0000000..13fdb92 --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/DataBase.java @@ -0,0 +1,28 @@ +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 + .getConnection("jdbc:postgresql://localhost:5432/Bootcamp_th", + "postgres", "postgres"); + + 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; + } +}