Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 3DF4F1336B42 for ; Tue, 7 Dec 2010 09:50:48 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 19640-08 for ; Tue, 7 Dec 2010 13:50:41 +0000 (UTC) X-Greylist: delayed 00:21:18.266704 by SQLgrey-1.7.6 Received: from mailout1.pacific.net.au (mailout1-2.pacific.net.au [61.8.2.209]) by mail.postgresql.org (Postfix) with ESMTP id 56C4E133655C for ; Tue, 7 Dec 2010 09:50:39 -0400 (AST) Received: from [187.65.247.222] (unknown [187.65.247.222]) by mailout1.pacific.net.au (Postfix) with ESMTP id 4C1A95DCB1E for ; Wed, 8 Dec 2010 00:29:14 +1100 (EST) Subject: Connection Problem From: Rob Stone To: pgsql-jdbc@postgresql.org Content-Type: multipart/mixed; boundary="=-qguS6oFO8w5iyyF7EBSz" Date: Wed, 08 Dec 2010 00:29:04 +1100 Message-ID: <1291728544.3489.28.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201012/36 X-Sequence-Number: 21274 --=-qguS6oFO8w5iyyF7EBSz Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Good morning, I don't know if I've done something really stupid or if I've stumbled on a bug. Run Debian on my laptop, version 2.6.32-3-686. Downloaded the PostgreSQL 9.0.1 source and compiled it following all the instructions. Downloaded the PGAdminIII 1.12 source plus heaps of .cpp files, compiled it. I can access the 9.0 database via psql or PGAdmin, view the database I created, display data in tables. (Not much to display at present but some rows exists in a couple of tables.) Downloaded the JDBC driver postgresql-9.0-801.jdbc4.jar, put it in my CLASSPATH, etc. Downloaded the latest version of ExecuteQuery, declared the new driver, created a connection to my 9.0 database using the new driver but unable to connect to the database. See stack trace attached. Postmaster is started with the -i option which I believe is the same as saying "listen_addresses='*'". Using jdk1.6. Wrote a mickey mouse java class (testdbconn) to see if I could access the database and read data from a table that has two rows. See attached. When it runs it displays the same SQL error code as ExecuteQuery -- 08001 -- which is the "can't connect error". The developer of ExecuteQuery is a former colleague of mine and a friend. We have been sending each other e-mails about this trying to suss out the problem. Obviously, I have installed something incorrectly OR there is something awry with java making the connection. psql and PGAdmin talk directly to the database without using a JDBC driver. Seeing as they are both functioning normally, what have I done to cause java to pull connect errors??? Any advice will be greatly appreciated. Cheers, Rob --=-qguS6oFO8w5iyyF7EBSz Content-Disposition: attachment; filename="testdbconn.java" Content-Type: text/x-java; name="testdbconn.java"; charset="UTF-8" Content-Transfer-Encoding: 7bit import java.sql.*; import java.io.*; import javax.sql.DataSource; public class testdbconn { static String dbname = "aerobook"; static String dbuser = "aerobook"; static String dbpass = "aerobook"; static String dbhost = "localhost"; static String dbport = "5432"; static String dbtable = "companies"; public static void main(String[] args) throws Exception { try { DriverManager.registerDriver(new org.postgresql.Driver()); Class.forName("org.postgresql.Driver").newInstance(); String url = "jdbc:postgresql://" + dbhost + ":" + dbport + "/" + dbname; System.out.println("getConnection: url="+url); Connection conn = DriverManager.getConnection(url, dbuser, dbpass); Statement s = conn.createStatement(); String query = "select * from companies"; ResultSet rs; rs = s.executeQuery(query); while(rs.next()) { System.out.print(rs.getString("airline_code")); System.out.println(" - " + rs.getString("airline_name")); } s.close(); } catch (SQLException s) { System.out.println("SQL Error: " + s.toString() + " " + s.getErrorCode() + " " + s.getSQLState()); } catch (Exception e) { System.out.println("Error: " + e.toString() + e.getMessage()); } } } --=-qguS6oFO8w5iyyF7EBSz Content-Disposition: attachment; filename="eqstacktrace.txt" Content-Type: text/plain; name="eqstacktrace.txt"; charset="UTF-8" Content-Transfer-Encoding: 7bit org.postgresql.util.PSQLException: The connection attempt failed. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:150) at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66) at org.postgresql.jdbc2.AbstractJdbc2Connection.(AbstractJdbc2Connection.java:125) at org.postgresql.jdbc3.AbstractJdbc3Connection.(AbstractJdbc3Connection.java:30) at org.postgresql.jdbc3.Jdbc3Connection.(Jdbc3Connection.java:24) at org.postgresql.Driver.makeConnection(Driver.java:393) at org.postgresql.Driver.connect(Driver.java:267) at org.executequery.datasource.SimpleDataSource.getConnection(SimpleDataSource.java:100) at org.executequery.datasource.SimpleDataSource.getConnection(SimpleDataSource.java:80) at org.executequery.datasource.ConnectionPoolImpl.createConnection(ConnectionPoolImpl.java:198) at org.executequery.datasource.ConnectionPoolImpl.ensureCapacity(ConnectionPoolImpl.java:159) at org.executequery.datasource.ConnectionPoolImpl.setMinimumConnections(ConnectionPoolImpl.java:328) at org.executequery.datasource.ConnectionManager.createDataSource(ConnectionManager.java:87) at org.executequery.databasemediators.spi.DefaultConnectionBuilder.createDataSource(DefaultConnectionBuilder.java:123) at org.executequery.databasemediators.spi.DefaultConnectionBuilder.access$000(DefaultConnectionBuilder.java:35) at org.executequery.databasemediators.spi.DefaultConnectionBuilder$1.construct(DefaultConnectionBuilder.java:100) at org.underworldlabs.swing.util.SwingWorker$2.run(SwingWorker.java:130) at java.lang.Thread.run(Thread.java:619) Caused by: java.net.SocketException: Network is unreachable at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:519) at java.net.Socket.connect(Socket.java:469) at java.net.Socket.(Socket.java:366) at java.net.Socket.(Socket.java:180) at org.postgresql.core.PGStream.(PGStream.java:62) at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:76) ... 17 more --=-qguS6oFO8w5iyyF7EBSz Content-Disposition: attachment; filename="tdbconnout.txt" Content-Type: text/plain; name="tdbconnout.txt"; charset="UTF-8" Content-Transfer-Encoding: 7bit rob@roblaptop:bin> ./java testdbconn getConnection: url=jdbc:postgresql://localhost:5432/aerobook SQL Error: org.postgresql.util.PSQLException: The connection attempt failed. 0 08001 rob@roblaptop:bin> --=-qguS6oFO8w5iyyF7EBSz--