From: | Paul Thomas <paul(at)tmsl(dot)demon(dot)co(dot)uk> |
---|---|
To: | "pgsql-jdbc (at) postgresql (dot) org" <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: connectivity problem |
Date: | 2004-01-30 11:22:23 |
Message-ID: | 20040130112223.A6795@bacon |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
On 30/01/2004 09:51 adp adp wrote:
> 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(at)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(at)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.
1) You haven't told told the postmaster where it's data directory is
2) The error message shows you what to do to correct this
3) I find it easier to edit postgresql.conf to set tcpip_socket = true
4) Unless you installed PostgreSQL yourself from source, it's probably
available as a service. Consult your OS/distribution documentation
5) I'd suggest you move your JDK to a directory under /usr. Either
/usr/java or /usr/local/java would be ok. Otherwise you're going to have
to run all your Java apps as root and that would be _really_ stupid.
--
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for the Smaller
Business |
| Computer Consultants |
http://www.thomas-micro-systems-ltd.co.uk |
+------------------------------+---------------------------------------------+
From | Date | Subject | |
---|---|---|---|
Next Message | mohan | 2004-01-30 16:04:21 | PROBLEM SOLVEDRe: java.lang.StringIndexOutOfBoundsException: String index |
Previous Message | adp adp | 2004-01-30 09:51:09 | connectivity problem |