Robię wszystko jak w tutorialach. JDBC zainstalowałem dodając zależność do Mavena:
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.14</version>
</dependency>
w przypadku sqlite coś takiego wystarczy, i wszystko działa.
Tutaj natomiast wyskakuje błąd:
Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
moja funkcja do łączenia z bazą:
private Connection connectPostgreSQL()
{
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;
}
Wszystko skopiowane bezpośrednio z tutorialu.