Java + postegre connection problem in Heroku

Asked

Viewed 255 times

0

Trying to connect java to the Heroku database (postgre), I have checked the url several times and there are no errors. I am not using Hibernate. By pgadmin I can enter it into the database normally. How to fix this error? Should I make a change to pom.xml?

private static Connection getConnection() {
    try {
        String dbUrl = "jdbc:postgresql://ec2-54-83-27-147.compute-1.amazonaws.com:5432/d1o8bcicho5jj?user=usuario&password=senha&sslmode=require";
        return DriverManager.getConnection(dbUrl);
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return null;
}

Error:

java.sql.Sqlexception: No suitable driver found for jdbc:postgresql://ec2...

pom.xml:

<dependency>
    <groupId>postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>9.0-801.jdbc4</version>
</dependency>
  • Downloaded and added the postgree driver to JDBC in the project’s classpath?

  • Even though I won’t run locally I need the driver?

  • 1

    ALWAYS! The driver is a kind of translator, without it the bank will not understand any commands you pass, so that error arises.

  • I edited with a part of the pom, the driver would be that?

  • Or should I download and put in the classpath msm?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.