I am using postgreSQL 7.3,j2sdk1.4.2 and have
installed jdbc driver as pg73jdbc3.jar
Here is the classpath :
exportCLASSPATH=/root/j2sdk1.4.2/bin/test1.java:/root/j2sdk_nb/j2sdk1.4.2/jre/lib/ext/pg73jdbc3.jar:.
and here is the code:
import java.sql.*;
class test2{
public static void main (String args[]) {
try{
Class.forName("org.postgresql.Driver");
String
url="jdbc:postgresql://127.0.0.1/test";
Connection con =
DriverManager.getConnection(url, "postgres", "");
Statement stm= con.createStatement();
stm.setQueryTimeout(10);
ResultSet rs = stm.executeQuery("select col1 from
test1");
rs.next();
System.out.println(rs.getString(1));
}catch(ClassNotFoundException e) {
System.out.println("Exception");
System.out.println(e.toString());
}
catch(SQLException e) {
System.out.println("Exception");
System.out.println(e.toString());
}
}
}
and now I receive this error irrespective of the host
and port address used in the url:
Exception
Connection refused. Check that the hostname and port
are correct and that the postmaster is accepting
TCP/IP connections.
next I tried the foll:
[root@ws128 bin]# postmaster -c tcpip_socket=true
"root" execution of the PostgreSQL server is not
permitted.
The server must be started under an unprivileged user
id to prevent
a possible system security compromise. See the
documentation for
more information on how to properly start the server.
Then I tried this:
[root@ws128 bin]# su postgres
bash-2.05b$ postmaster -c tcpip_socket=true
postmaster does not know where to find the database
system data.
You must specify the directory that contains the
database system
either by specifying the -D invocation option or by
setting the
PGDATA environment variable.
I think the problem is with postmaster settings, I
tried to set tcpip_socket into the postgresql.conf
file but it didnt work.
Please help.
________________________________________________________________________
Yahoo! India Mobile: Download the latest polyphonic ringtones.
Go to http://in.mobile.yahoo.com