From: | Bob VonMoss <bvonmoss(at)bigfoot(dot)com> |
---|---|
To: | PostGreSQL General List <pgsql-general(at)postgresql(dot)org> |
Subject: | connecting: unix socket? Yes. TCPIP port? No. -i? Yes. |
Date: | 1999-02-06 04:56:36 |
Message-ID: | 36BBCB84.6D9C02C0@bigfoot.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I'm just getting into PostGreSQL and would ultimately like to
communicate from a java/JDBC applet through the web with PostGreSQL on a
Solaris unix system. I've had a user account created for me. I'm able to
do everything so far from the commandline through unix sockets by
running 'psql' and 'createdb mydb'.
I began experimenting with JDBC and was having problems connecting, so I
put the java application on the same system where PostGreSQL is and was
getting the same 'user authentication failed...' messages. I then tried
altering the jdbc URL to specify the database only without the internet
host name and it worked successfully.
I changed this statement in the code below:
con = DriverManager.getConnection(
"jdbc:postgresql://my-isp.com/mydb","mylogin","mypwd");
to (since I was local):
con = DriverManager.getConnection(
"jdbc:postgresql:mydb","mylogin","mypwd");
and it worked on the local machine.
The error was:
bash$ java pCon
registering postgresql.Driver...
connecting to the PostGreSQL DB...
java.sql.SQLException: User authentication failed
bash$
I noticed in the docs that you can channel psql through TCPIP ports
rather than unix sockets. I tried it (with my real names) and get this:
bash$ psql -h my-isp.com -d mydb
Connection to database 'mydb' failed.
User authentication failedbash$
bash$ psql -h my-isp.com -p 5432 -d mydb
Connection to database 'mydb' failed.
User authentication failedbash$
I also tried setting PGHOST to my-isp.com, which responded the same.
The administrator says this is how postmaster is invoked:
/usr/local/pgsql/bin/postmaster -S -i -D /usr/local/pgsql/data -p 5432
// pCon.java
import java.io.*;
import java.sql.*;
public class pCon {
public pCon() { }
public static void main(String[] args) throws Exception
{
System.out.println("registering postgresql.Driver...");
Connection con;
try {
Class.forName("postgresql.Driver");
} catch (Exception e) {
System.out.println(""+e);
return;
}
System.out.println("connecting to the PostGreSQL DB...");
try {
con = DriverManager.getConnection(
"jdbc:postgresql://my-isp.com/mydb","mylogin","mypwd");
} catch (SQLException se) {
System.out.println(""+se);
return;
}
System.out.println(
"closing connection to the PostGreSQL DB...");
try {
con.close();
} catch (SQLException se) {
System.out.println(""+se);
}
System.out.println(
"connection to the PostGreSQL DB closed successfully");
}
}
--
Bob VonMoss
mailto:bvonmoss(at)bigfoot(dot)com
from Chicago, IL
From | Date | Subject | |
---|---|---|---|
Next Message | KoPra Workshop | 1999-02-06 09:00:26 | postmaster confiugration and hardware configuration |
Previous Message | Jonny Hinojosa | 1999-02-06 03:25:35 | Oooops, I think I booboo'd |