Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.databases > #44

Connection to Db

From "Vedran" <vedran@THRWHITE.remove-dii-this>
Subject Connection to Db
Message-ID <fv57c6$3fj$1@news1.carnet.hr> (permalink)
Newsgroups comp.lang.java.databases
Date 2011-04-27 15:21 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.databases
Hello!

When trying to connect to a Db I gat the following exception:

org.postgresql.util.PSQLException: The connection attempt failed.
	at
org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:136)
	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.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
	at org.postgresql.Driver.makeConnection(Driver.java:382)
	at org.postgresql.Driver.connect(Driver.java:260)
	at java.sql.DriverManager.getConnection(DriverManager.java:582)
	at java.sql.DriverManager.getConnection(DriverManager.java:154)
	at hr.fer.tel.smfrontend.dbaccess.DbAccess.connectToDB(DbAccess.java:38)
	at
hr.fer.tel.smfrontend.dbaccess.DbTestTemplate.<init>(DbTestTemplate.java:21)
	at
hr.fer.tel.smfrontend.dbaccess.DbAccessValidTonesTest.<init>(DbAccessValidTonesTest.java:14)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at
org.junit.internal.runners.TestClassMethodsRunner.createTest(TestClassMethodsRunner.java:52)
	at
org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:58)
	at
org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
	at
org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
	at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
	at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
	at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
	at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.net.UnknownHostException: stormflock.bla.bla.bla
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
	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.<init>(Socket.java:366)
	at java.net.Socket.<init>(Socket.java:180)
	at org.postgresql.core.PGStream.<init>(PGStream.java:59)
	at
org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:77)
	... 27 more


I believe that only interesting part is: java.net.UnknownHostException:
stormflock.bla.bla.bla

I changed real computer name to stormflock.bla.bla.bla. This exception
is quite unexpected because, I can access this machine. For example:

ping stormflock.bla.bla.bla works without a problem.

Exception is thrown in the line:

DbAccess.connection = DriverManager.getConnection(url, props);

try {
			Class.forName("org.postgresql.Driver").newInstance();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
		String url = "jdbc:postgresql://" + dbServer + "/" + dbName;
		Properties props = new Properties();
		props.setProperty("user",userName);
		props.setProperty("password",passwd);
		props.setProperty("ssl","true");
		DbAccess.connection = DriverManager.getConnection(url, props);


If I write an IP addess of the server, then the exception is not thrown,
but the connecting fails at some other error. I believe that these two
errors are somehow connected, because the same code worked before. I
guess something is wrong with my Java config, but I do not know what.

All the help would be greatly appreciated.

Thanks in advance!

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.databases | Previous | Next | Find similar


Thread

Connection to Db "Vedran" <vedran@THRWHITE.remove-dii-this> - 2011-04-27 15:21 +0000

csiph-web