public class ConnectionDB private final String driverClassName org pos

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
public class ConnectionDB {
private final String driverClassName = "org.postgresql.Driver";
private final String connectionUrl = "jdbc:postgresql://ыфвфы лвофды";
private final String dbUser = "postgre";
private final String dbPwd = "1233333";
private static ConnectionFactory connectionDB = null;
private ConnectionDB() {
try {
Class.forName(driverClassName);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public Connection getConnection() throws SQLException {
Connection conn = null;
conn = DriverManager.getConnection(connectionUrl, dbUser, dbPwd);
return conn;
}
public static ConnectionDB getInstance() {
if (connectionFactory == null) {
connectionFactory = new ConnectionFactory();
}
return connectionDB;
}
}