0

I am expirencing a problem with the JDBC driver. My database is at postgres://... but the driver only works with postgresql://.... What should I do?

I am trying to connect to a heroku postgres database from java.

CODE:

Connection conn = null;

Below I am trying with postgresql://

Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection("jdbc:postgresql://bfjxvagjalvmcu:n9Y2VO0myQ5sgWVrzJbLX59TD3@ec2-54-204-15-41.compute-1.amazonaws.com:5432/*****&username=******&password=******&ssl=true");

And I get the error:

org.postgresql.util.PSQLException: The connection attempt failed.

And if I use this code, with postgres

Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection("jdbc:postgres://bfjxvagjalvmcu:n9Y2VO0myQ5sgWVrzJbLX59TD3@ec2-54-204-15-41.compute-1.amazonaws.com:5432/****&username=******&password=****&ssl=true");

I get the error:

java.sql.SQLException: No suitable driver found for jdbc:postgres://bfjxvagjalvmcu:n9Y2VO0myQ5sgWVrzJbLX59TD3@ec2-54-204-15-41.compute-1.amazonaws.com:5432/*******&username=********&password=*******&ssl=true
thesecretmaster
  • 1,950
  • 1
  • 27
  • 39
  • 3
    Could you show exception? Would be much more efficient to track down issue. – Paweł Głowacz Jul 10 '15 at 11:37
  • My Postgres connection starts with "jdbc:postgresql://..." – Adam Horvath Jul 10 '15 at 11:39
  • "*The connection attempt failed*" seems to indicate that your connection credentials are wrong somehow. I don't see any indication that there is a "hostname" error. Maybe a SSL problem: See here: http://stackoverflow.com/q/9386803/330315 or here: http://stackoverflow.com/q/11832361/330315 –  Jul 10 '15 at 11:51
  • 1
    `jdbc:postgresql:` is correct one. – Madhawa Priyashantha Jul 10 '15 at 11:51
  • 1
    Are you sure, that your machine can access your RDS? There is an [article](http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.html) regarding VPC configuration at AWS, which may help you. – user3707125 Jul 10 '15 at 11:53
  • What happens when you run `ping ec2-54-204-15-41.compute-1.amazonaws.com` on the command line of your operating system? –  Jul 10 '15 at 11:59
  • Before connecting to the real database test connection url with Eclipse Data Tools. – Roman C Jul 10 '15 at 12:07

0 Answers0