You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

34 lines
964 B

package dto;
// import constants.PSGQL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectDB{
// private final String url = "jdbc:postgresql://localhost/dvdrental";
// private final String user = "postgres";
// private final String password = "<add your password>";
private final String url = "jdbc:postgresql://localhost:5432/scandb";
private final String user = "postgres";
private final String password = "password";
/**
* Connect to the PostgreSQL database
*
* @return a Connection object
*/
public Connection connect() {
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
System.out.println("Connected to the PostgreSQL server successfully.");
} catch (SQLException e) {
System.out.println(e.getMessage());
}
return conn;
}
}