View Single Post
Old 12-13-2003, 03:45 AM   #1 (permalink)
Moskie
Pure Chewing Satisfaction
 
Moskie's Avatar
 
Location: can i use bbcode [i]here[/i]?
Java/JDBC/postgresql problems

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?
__________________
Greetings and salutations.
Moskie is offline  
 

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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73