connecting: unix socket? Yes. TCPIP port? No. -i? Yes.

Поиск
Список
Период
Сортировка
От Bob VonMoss
Тема connecting: unix socket? Yes. TCPIP port? No. -i? Yes.
Дата
Msg-id 36BBBA90.67C72C26@bigfoot.com
обсуждение исходный текст
Ответы Re: [INTERFACES] connecting: unix socket? Yes. TCPIP port? No. -i? Yes.  (James Thompson <jamest@math.ksu.edu>)
Re: [INTERFACES] connecting: unix socket? Yes. TCPIP port? No. -i? Yes.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-interfaces
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@bigfoot.com
from Chicago, IL



В списке pgsql-interfaces по дате отправления:

Предыдущее
От: hoelc
Дата:
Сообщение: (no subject)
Следующее
От: James Thompson
Дата:
Сообщение: Re: [INTERFACES] connecting: unix socket? Yes. TCPIP port? No. -i? Yes.