Skip to content

Instantly share code, notes, and snippets.

@JFRode
Last active May 3, 2016 00:23
Show Gist options
  • Save JFRode/72ac675b9147664906823f2e095163c2 to your computer and use it in GitHub Desktop.
Save JFRode/72ac675b9147664906823f2e095163c2 to your computer and use it in GitHub Desktop.
heroku JDBC connection
// credit /okedokee
private final String JDBC = "postgresql";
private final String HOST = "";
private final String PORT = "5432";
private final String DATABASE = "";
private final String USER = "";
private final String PASSWORD = "";
private final String DRIVER = "org.postgresql.Driver";
private String url;
private Connection conexao;
public Conexao() {
try {
url = "jdbc:" + JDBC + "://" + HOST + ":" + PORT + "/" + DATABASE;
Properties prop = new Properties();
prop.setProperty("user", USER);
prop.setProperty("password", PASSWORD);
prop.setProperty("ssl", "true");
prop.setProperty("sslfactory", "org.postgresql.ssl.NonValidatingFactory");
conexao = DriverManager.getConnection(url, prop);
} catch (SQLException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment