I'm trying to make a connection to the ElephantSQL (postgres) through java. With the same code I have already been able to connect to local postgres (just changing the url, user, password). I'm trying to do this:
private static final String DRIVER = "org.postgresql.Driver";
private static final String URL = "jdbc:postgres://nklbcxow:[email protected]:5432/nklbcxow";
private static final String USER = "nklbcxow";
private static final String PASS = "MINHA_SENHA_NO_ELEPHANTSQL";
public static Connection getConnection() throws SQLException {
try {
Class.forName(DRIVER);
return DriverManager.getConnection(URL, USER, PASS);
} catch (ClassNotFoundException ex) {
throw new RuntimeException("Erro na conexão", ex);
}
}
But there is a Driver error:
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc: postgres: // nklbcxow: [email protected]: 5432 / nklbcxow at java.sql.DriverManager.getConnection (DriverManager.java:689) at java.sql.DriverManager.getConnection (DriverManager.java:247) at ConnectionFactory.getConnection (ConnectionFactory.java:20) at ProductDa.registerTemp (ProductDAO.java:20) at BDLearning.main (BDLearning.java:25) C: \ Users \ mathe \ AppData \ Local \ NetBeans \ Cache \ 8.2 \ executor-snippets \ run.xml: 53: Java returned: 1 CONSTRUCTION FAIL (total time: 0 seconds)
Since the site itself is indicating the driver I'm already using:
I think it's some format in the url that I'm not aware of, I've tried it in some other ways, but no funciounou.
On their site there is a doc that gives an example of how to do in java, I copied the example and continued giving problem