Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ConnectionManager {
- /**
- * Klasa inicjalizujaca polaczenia z baza danych
- * @return obiekt klasy java.sql.Connection opisujacy polaczenie
- * @throws SQLException
- */
- public static Connection InitializeConnection() throws SQLException{
- try {
- Class.forName("org.postgresql.Driver");
- } catch (ClassNotFoundException e) {
- System.out.println("Bład ładowania driverem" + e);
- e.printStackTrace();
- System.exit(-4);
- }
- ConnectionConfiguration conf = ConfigurationManager.getConfiguration();
- int port =0;
- String host = "";
- if(conf.isConfigured()){
- port = conf.getPort();
- host = conf.getHost();
- } else {
- port = conf.getDefaultPort();
- host = conf.getDefaultHost();
- }
- String address = "jdbc:postgresql://" + host+":"
- +port + "/u3wieczorek";
- db = DriverManager.getConnection(address, "u3wieczorek", "3wieczorek");
- return db;
- }
- /**
- * obiekt klasy java.sql.Connection
- * pozwalacjacy m.in wysylaczapytania do bazy
- */
- public static Connection db;
- public static String userRole = null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement