java.net.SocketException: Network is unreachable - Mailing list pgsql-jdbc
From | Wolfgang Rinnert |
---|---|
Subject | java.net.SocketException: Network is unreachable |
Date | |
Msg-id | 1264618959.4222.2.camel@pcwolfgang.weser12a Whole thread Raw |
Responses |
Re: java.net.SocketException: Network is unreachable
|
List | pgsql-jdbc |
Hello list, since I switched from a AMD Athlon based 32bit single core machine to a 64bit quad-core, a cannot run my Postgresql Java programs. I do everything using Debian testing. The new machine was installed from scratch. Here is the output of "uname -a": Linux pcwolfgang 2.6.30-2-amd64 #1 SMP Mon Dec 7 05:21:45 UTC 2009 x86_64 GNU/Linux I migrated using pg_dump / psql -i without problems. On the old machine I had postgresql 8.3, now I have 8.4. Details below. The old jdbc driver was called postgresql-8.3-603.jdbc4.jar, currently I have postgresql-8.4-701.jdbc4.jar. I can see and modify my data through psql (through socket as well as tcp/ip access). But running a java program gives me an exception crash. Now for the details. I have put the statements between lines of equal signs, their output directly following. ================================================================ postgres@pcwolfgang:/root $ /usr/lib/postgresql/8.4/bin/pg_controldata ================================================================ pg_control-Versionsnummer: 843 Katalogversionsnummer: 200904091 Datenbanksystemidentifikation: 5420760379678260442 Datenbank-Cluster-Status: im Produktionsmodus pg_control zuletzt geändert: Mo 25 Jan 2010 18:04:48 CET Position des letzten Checkpoints: 0/9B91F8 Position des vorletzten Checkpoints: 0/9B91B0 REDO-Position des letzten Checkpoints: 0/9B91F8 TimeLineID des letzten Checkpoints: 1 NextXID des letzten Checkpoints: 0/17583 NextOID des letzten Checkpoints: 16545 NextMultiXactId des letzten Checkpoints: 1 NextMultiOffset des letzten Checkpoints: 0 Zeit des letzten Checkpoints: So 24 Jan 2010 23:35:16 CET Minimaler Wiederherstellungsendpunkt: 0/0 Maximale Datenausrichtung (Alignment): 8 Datenbankblockgröße: 8192 Blöcke pro Segment: 131072 WAL-Blockgröße: 8192 Bytes pro WAL-Segment: 16777216 Maximale Bezeichnerlänge: 64 Maximale Spalten in einem Index: 32 Maximale Größe eines Stücks TOAST: 1996 Speicherung von Datum/Zeit-Typen: 64-Bit-Ganzzahlen Übergabe von Float4-Argumenten: Wert Übergabe von Float8-Argumenten: Wert ================================================================ wolfgang@pcwolfgang:~$ pg_lsclusters ================================================================ Version Cluster Port Status Owner Data directory Log file 8.4 main 5432 online postgres /var/lib/postgresql/8.4/main /var/log/postgresql/postgresql-8.4-main.log ================================================================ postgres@pcwolfgang:/root$ ps aux | grep -i post ================================================================ postgres 2115 0.0 0.3 102320 6428 ? S 18:04 0:01 /usr/lib/postgresql/8.4/bin/postgres -D /var/lib/postgresql/8.4/main -c config_file=/etc/postgresql/8.4/main/postgresql.conf postgres 2120 0.0 0.0 102320 1688 ? Ss 18:04 0:00 postgres: writer process postgres 2121 0.0 0.0 102320 1484 ? Ss 18:04 0:00 postgres: wal writer process postgres 2122 0.0 0.1 102600 1920 ? Ss 18:04 0:00 postgres: autovacuum launcher process postgres 2123 0.0 0.0 74012 1588 ? Ss 18:04 0:00 postgres: stats collector process postgres 3731 0.0 0.0 49356 1568 pts/0 S 18:34 0:00 su postgres postgres 3739 0.0 0.1 18964 1932 pts/0 S 18:34 0:00 bash postgres 3748 0.0 0.0 16072 1116 pts/0 R+ 18:35 0:00 ps aux postgres 3749 0.0 0.0 9348 936 pts/0 R+ 18:35 0:00 grep -i post This is the call to a little example java program. Its code follows below. Translation of the phrase in German "Der Verbindungsversuch schlug fehl." would be "The connection attempt failed." ================================================================ wolfgang@pcwolfgang:~/programming/java/lotto$ java jdbc_002_driverinfo ================================================================ 18:13:26.852 (1) PostgreSQL 8.4 JDBC4 (build 701) 18:13:26.878 (1) Trying to establish a protocol version 3 connection to 127.0.0.1:5432 org.postgresql.util.PSQLException: Der Verbindungsversuch schlug fehl. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:150) at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66) at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125) at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30) at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22) at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:30) at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24) at org.postgresql.Driver.makeConnection(Driver.java:393) at org.postgresql.Driver.access $100(Driver.java:47) at org.postgresql.Driver $ConnectThread.run(Driver.java:308) at java.lang.Thread.run(Thread.java:619) SQLException: SQLState(08001) getConnection failed: org.postgresql.util.PSQLException: Der Verbindungsversuch schlug fehl. Exception in thread "main" org.postgresql.util.PSQLException: Der Verbindungsversuch schlug fehl. at org.postgresql.Driver $ConnectThread.getResult(Driver.java:348) at org.postgresql.Driver.connect(Driver.java:271) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:154) at jdbc_002_driverinfo.main(jdbc_002_driverinfo.java:19) 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:525) at java.net.Socket.connect(Socket.java:475) at java.net.Socket.<init>(Socket.java:372) at java.net.Socket.<init>(Socket.java:186) at org.postgresql.core.PGStream.<init>(PGStream.java:62) at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:76) at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66) at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125) at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30) at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22) at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:30) at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24) at org.postgresql.Driver.makeConnection(Driver.java:393) at org.postgresql.Driver.access $100(Driver.java:47) at org.postgresql.Driver $ConnectThread.run(Driver.java:308) at java.lang.Thread.run(Thread.java:619) This is my little example java program. I have tried all commented-out versions you will see in the code. One astounding thing is that I get the same exceptions thrown when postmaster is not running. To me it seems that the jdbc driver does not see the database *at all*. How this can be, is a complete mystery to me. My setup, which did not do any harm on the previous environment, may be flawed. But one way or the other, I do not know how to proceed. ================================================================ wolfgang@pcwolfgang:~/programming/java/lotto$ cat jdbc_002_driverinfo.java ================================================================ import java.sql.*; import java.util.*; public class jdbc_002_driverinfo { public static void main( String args[] ) throws Exception { Class.forName( "org.postgresql.Driver" ); //Connection conn = DriverManager.getConnection( "jdbc:postgresql:lotto", "wolfgang", "null" ); //Connection conn = DriverManager.getConnection( "jdbc:postgresql://127.0.0.1:5432/lotto", "wolfgang", "" ); //String url = "jdbc:postgresql://localhost:5432/lotto"; String url = "jdbc:postgresql://127.0.0.1:5432/lotto"; Properties props = new Properties(); props.setProperty("user","wolfgang"); props.setProperty("password",""); props.setProperty("loglevel","2"); props.setProperty("socketTimeout","10"); props.setProperty("loginTimeout","10"); props.setProperty("tcpKeepAlive","true"); Connection conn = DriverManager.getConnection(url, props); DatabaseMetaData meta = conn.getMetaData(); System.out.println( "Produkt: " + meta.getDatabaseProductName() ); System.out.println( "Version: " + meta.getDatabaseProductVersion() ); System.out.println( "Anzahl erlaubter Verbindungen: " + meta.getMaxConnections() ); System.out.println( "Version des DB-Treibers : " + meta.getDriverVersion() ); System.out.println( "Update im Batchbetrieb : " + meta.supportsBatchUpdates() ); System.out.println( "Gespeicherte Prozeduren : " + meta.supportsStoredProcedures() ); conn.close (); } } Last, here is the extract of my postgresql configuration. Pretty much standard. ================================================================ pcwolfgang:~# grep ^[[:alpha:]] /etc/postgresql/8.4/main/postgresql.conf | cut -d"#" -f 1 ================================================================ data_directory = '/var/lib/postgresql/8.4/main' hba_file = '/etc/postgresql/8.4/main/pg_hba.conf' ident_file = '/etc/postgresql/8.4/main/pg_ident.conf' external_pid_file = '/var/run/postgresql/8.4-main.pid' listen_addresses = 'localhost, 127.0.0.1' port = 5432 max_connections = 100 unix_socket_directory = '/var/run/postgresql' ssl = false shared_buffers = 24MB syslog_facility = 'LOCAL0' syslog_ident = 'postgres' client_min_messages = log log_min_messages = info log_min_error_statement = info log_line_prefix = '%t ' datestyle = 'iso, dmy' lc_messages = 'de_DE.UTF-8' lc_monetary = 'de_DE.UTF-8' lc_numeric = 'de_DE.UTF-8' lc_time = 'de_DE.UTF-8' default_text_search_config = 'pg_catalog.german' The database and all clients accessing it are strictly local. So, basically I have no access restrictions. ================================================================ pcwolfgang:~# grep -v ^$ /etc/postgresql/8.4/main/pg_hba.conf | grep -v ^# ================================================================ local postgres postgres trust local all postgres ident local all wolfgang trust host all wolfgang 127.0.0.1/32 trust host all wolfgang ::1/128 trust Any help is very much appreciated. Regards, Wolfgang Rinnert
pgsql-jdbc by date: