connectivity problem

From: adp adp <adp_group2004(at)yahoo(dot)co(dot)in>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: connectivity problem
Date: 2004-01-30 05:46:59
Message-ID: 20040130054659.42810.qmail@web8106.mail.in.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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");
// DriverManager.registerDriver(new (Driver));




String url="jdbc:postgresql: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 here is the error I receive :

Exception
The connection attempt failed because Exception:
java.net.UnknownHostException: localhost
Stack Trace:

java.net.UnknownHostException: localhost
at
java.net.PlainSocketImpl.connect(PlainSocketImpl.java:153)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at java.net.Socket.<init>(Socket.java:309)
at java.net.Socket.<init>(Socket.java:124)
at
org.postgresql.PG_Stream.<init>(PG_Stream.java:38)
at
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:160)
at
org.postgresql.Driver.connect(Driver.java:122)
at
java.sql.DriverManager.getConnection(DriverManager.java:512)
at
java.sql.DriverManager.getConnection(DriverManager.java:171)
at test2.main(test2.java:13)
End of Stack Trace

________________________________________________________________________
Yahoo! India Mobile: Download the latest polyphonic ringtones.
Go to http://in.mobile.yahoo.com

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2004-01-30 05:54:34 Re: connectivity problem
Previous Message Kris Jurka 2004-01-30 05:01:42 Re: connectivity problem