Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Databases > Connection to D...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 3737 of 3747
Post > Topic >>

Connection to Db

by Vedran <ab@[EMAIL PROTECTED] > Apr 28, 2008 at 09:08 PM

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!




 1 Posts in Topic:
Connection to Db
Vedran <ab@[EMAIL PROT  2008-04-28 21:08:55 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 22:36:05 CDT 2008.