Re: [GENERAL] Re: Unsupported frontend protocol - libpq

1999-04-04 Thread Bob VonMoss

Yes, I can connect via JDBC and via 'psql -h mypghost.com mydb'

Statistical Solutions wrote:

 Are you running postgres with the -i option???  For postgres to work with
 tcp/ip, you need to launch postmaster with the -i option.

 steve

 On Sat, 3 Apr 1999, Bob VonMoss wrote:

  Bob VonMoss wrote:
 
   I'm trying to connect to a database from a C++ program compiled with
   g++, linked to the libpq library on a Sun Solaris system. It is compiled
   and run like this (my actual information has been changed to pseudonyms,
   like mypghost.com, etc.)
  
   bash$ gmake
   g++ -c -I /usr/local/pgsql/include test1.cpp
   g++ -o test1 test1.o -L. -lpq -lsocket -lnsl
 
  I suppose my problem is here. I'm connecting via TCPIP not sockets. What
  libraries? I can't find this documented in the PG docs.
 
   bash$ test1
   Connection to database 'mydb' failed.
   Unsupported frontend protocol.bash$
  
   It's failing at the command in the code below. No matter I try, I'm
   getting the "Unsupported frontend protocol" message.
  
   int main()
   {
   ...
   PGconn *conn;
   char* dbname = "mydb";
   /* make a connection to the database */
   conn = PQsetdbLogin("mypghost.com", NULL, NULL, NULL, dbname,
   "mylogin", "mypasswd");
  
   if (PQstatus(conn) == CONNECTION_BAD)
   {
   fprintf(stderr, "Connection to database '%s' failed.\n",
  
   dbName);
   fprintf(stderr, "%s", PQerrorMessage(conn));
           exit_nicely(conn);
   }
   ...
   }
  
   --
   Bob VonMoss
   mailto:[EMAIL PROTECTED]
   from Chicago, IL
 
  --
  Bob VonMoss
  mailto:[EMAIL PROTECTED]
  from Chicago, IL
 
 
 
 

--
Bob VonMoss
mailto:[EMAIL PROTECTED]
from Chicago, IL





Re: [GENERAL] Re: Unsupported frontend protocol - libpq

1999-04-04 Thread Bob VonMoss

The same thing is happening when I compile the sample program:
postgresql-6.4.2/src/test/examples/testlibpq.c
when I put my own database name and set some of the PG env. variables.

bash$ testlibpq
Connection to database 'mydb' failed.
Unsupported frontend protocol.bash$

Bob VonMoss wrote:

 Yes, I can connect via JDBC and via 'psql -h mypghost.com mydb'

 Statistical Solutions wrote:

  Are you running postgres with the -i option???
 
  On Sat, 3 Apr 1999, Bob VonMoss wrote:
 
   Bob VonMoss wrote:
  
I'm trying to connect to a database from a C++ program compiled with
g++, linked to the libpq library on a Sun Solaris system. It is compiled
and run like this (my actual information has been changed to pseudonyms,
like mypghost.com, etc.)
   
bash$ gmake
g++ -c -I /usr/local/pgsql/include test1.cpp
g++ -o test1 test1.o -L. -lpq -lsocket -lnsl
  
   I suppose my problem is here. I'm connecting via TCPIP not sockets. What
   libraries? I can't find this documented in the PG docs.
  
bash$ test1
Connection to database 'mydb' failed.
Unsupported frontend protocol.bash$
   
It's failing at the command in the code below. No matter I try, I'm
getting the "Unsupported frontend protocol" message.
   
int main()
{
...
PGconn *conn;
char* dbname = "mydb";
/* make a connection to the database */
conn = PQsetdbLogin("mypghost.com", NULL, NULL, NULL, dbname,
"mylogin", "mypasswd");
   
if (PQstatus(conn) == CONNECTION_BAD)
{
fprintf(stderr, "Connection to database '%s' failed.\n",
   
dbName);
fprintf(stderr, "%s", PQerrorMessage(conn));
        exit_nicely(conn);
}
...
}

--
Bob VonMoss
mailto:[EMAIL PROTECTED]
from Chicago, IL





[GENERAL] Unsupported frontend protocol - libpq

1999-04-03 Thread Bob VonMoss

I'm trying to connect to a database from a C++ program compiled with
g++, linked to the libpq library on a Sun Solaris system. It is compiled
and run like this (my actual information has been changed to pseudonyms,
like mypghost.com, etc.)

bash$ gmake
g++ -c -I /usr/local/pgsql/include test1.cpp
g++ -o test1 test1.o -L. -lpq -lsocket -lnsl
bash$ test1
Connection to database 'mydb' failed.
Unsupported frontend protocol.bash$

It's failing at the command in the code below. No matter I try, I'm
getting the "Unsupported frontend protocol" message.

int main()
{
...
PGconn *conn;
char* dbname = "mydb";
/* make a connection to the database */
conn = PQsetdbLogin("mypghost.com", NULL, NULL, NULL, dbname,
"mylogin", "mypasswd");

if (PQstatus(conn) == CONNECTION_BAD)
{
fprintf(stderr, "Connection to database '%s' failed.\n",

dbName);
fprintf(stderr, "%s", PQerrorMessage(conn));
exit_nicely(conn);
}
...
}

--
Bob VonMoss
mailto:[EMAIL PROTECTED]
from Chicago, IL





[GENERAL] Re: Unsupported frontend protocol - libpq

1999-04-03 Thread Bob VonMoss

Bob VonMoss wrote:

 I'm trying to connect to a database from a C++ program compiled with
 g++, linked to the libpq library on a Sun Solaris system. It is compiled
 and run like this (my actual information has been changed to pseudonyms,
 like mypghost.com, etc.)

 bash$ gmake
 g++ -c -I /usr/local/pgsql/include test1.cpp
 g++ -o test1 test1.o -L. -lpq -lsocket -lnsl

I suppose my problem is here. I'm connecting via TCPIP not sockets. What
libraries? I can't find this documented in the PG docs.

 bash$ test1
 Connection to database 'mydb' failed.
 Unsupported frontend protocol.bash$

 It's failing at the command in the code below. No matter I try, I'm
 getting the "Unsupported frontend protocol" message.

 int main()
 {
 ...
 PGconn *conn;
 char* dbname = "mydb";
 /* make a connection to the database */
 conn = PQsetdbLogin("mypghost.com", NULL, NULL, NULL, dbname,
 "mylogin", "mypasswd");

 if (PQstatus(conn) == CONNECTION_BAD)
 {
 fprintf(stderr, "Connection to database '%s' failed.\n",

 dbName);
 fprintf(stderr, "%s", PQerrorMessage(conn));
     exit_nicely(conn);
 }
 ...
 }

 --
 Bob VonMoss
 mailto:[EMAIL PROTECTED]
 from Chicago, IL

--
Bob VonMoss
mailto:[EMAIL PROTECTED]
from Chicago, IL





[GENERAL] libpq linking problem

1999-04-02 Thread Bob VonMoss

I'm starting to use libpq.a in a test C/C++ program, but am getting the
following the linker errors:

bash$ gmake
gcc -o test test.o libpq.a
Undefined   first referenced
 symbol in file
socket  libpq.a(fe-connect.o)
recvlibpq.a(fe-misc.o)
getprotobyname  libpq.a(fe-connect.o)
gethostbyname   libpq.a(fe-connect.o)
sendlibpq.a(fe-connect.o)
setsockopt  libpq.a(fe-connect.o)
getsockname libpq.a(fe-connect.o)
connect libpq.a(fe-connect.o)
ld: fatal: Symbol referencing errors. No output written to test
gmake: *** [test] Error 1
bash$

What library am I missing?
It looks like a system library with the tcpip functions.
I ran 'configure' and recompiled libpq.a

--
Bob VonMoss
mailto:[EMAIL PROTECTED]
from Chicago, IL





[GENERAL] restricting select statements

1999-02-24 Thread Bob VonMoss

I'm working with JDBC and if I issue a broad SELECT statement, with a
good amount of records (2000) it takes quite a while to execute the
query and send the results back, even up to a minute, when I only want
about the first 100 records. If I restrict the search, it is satisfied
in a much more reasonable amount of time. The problem is that I can only
know how big the database. I could do a count and get an idea of how
large the database is and make a guess that the data is uniformly
distributed. There was a java command to restrict the number of records
saved setMaxSize(); but this does not seem to decrease the time of
execution of executeQuery(), and probably only uses less local memory.

If I have a statement like:

SELECT * FROM a;

and only want about the first 150 records, is there a way of speeding up
the query without doing a count(*) on a and doing something like this:

SELECT * FROM a WHERE '' = a AND a  'C';

--
Bob VonMoss
mailto:[EMAIL PROTECTED]
from Chicago, IL





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

1999-02-06 Thread Bob VonMoss

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:[EMAIL PROTECTED]
from Chicago, IL