I'm having some difficulties connecting to my postgresql server through Java. Here's a run-down of how I've done things so far.
1. Got postgresql running form Cygwin, using the command "postmaster -D ~/db". It loads and eventually says "database system is ready".
2. I'm able to connect to a database I've created (called 'db') from another Cygwin prompt with "psql db". From that point, everything goes as planned. I can update/inspect the database as I please. This makes me think that the database is doing everything it should: it's running properly, is listening/responding as it should, and it's physcially possible to connect to this database.
3. Now trying to connect to this database from a Java program is giving me headaches. Using the line:
Code:
db = DriverManager.getConnection("jdbc:postgresql://localhost/db", "moskie", "oo2");
the following exception is thrown: "Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections." I've tried using different ports besides the default (using the '-p 65535' flag on postmaster, then trying to connect to 'localhost:65535'), but I get the same exception.
What am I doing wrong?