Java Utililty Methods JDBC PostgreSQL Connection

List of utility methods to do JDBC PostgreSQL Connection

Description

The list of methods to do JDBC PostgreSQL Connection are organized into topic(s).

Method

ConnectiongetPostgresSQLConnection(String hostname, int portNumber, String databaseName, String dbuser, String dbpasswort)
Gets the postgres sql connection from the given parameters.
StringBuilder sb = new StringBuilder();
sb.append(POSTGRESQL_PREFIX_URL);
sb.append(hostname);
sb.append(":");
sb.append(portNumber);
sb.append("/");
sb.append(databaseName);
Class.forName(POSTGRESQL_DRIVERNAME);
...
voidresetTestDB()
reset Test DB
if (connection == null) {
    try {
        connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/wegas_test", "user",
                "1234");
        try (Statement st = connection.createStatement()) {
            st.execute("DROP SCHEMA public CASCADE;");
            st.execute("CREATE SCHEMA public;");
        connection.commit();
    } catch (SQLException ex) {
        System.out.println("Error creating database");