Database Reference
In-Depth Information
JDBC
You can connect via JDBC using the DATABASE_URL variable or using another database
URL provided by Heroku. The JDBC connection is performed through the database URL
parsing and extracting the necessary parameters. The following is just a code sample to
help you understand the concept:
URI connectionParams = new
URI(System.getenv("DATABASE_URL"));
String jdbcUrl = "jdbc:postgresql://" +
connectionParams.getHost() + connectionParams.getPath();
Properties properties = new Properties();
properties.setProperty("username",
connectionParams.getUserInfo().split(":")[0]);
properties.setProperty("password",
connectionParams.getUserInfo().split(":")[1]);
Connection connection = DriverManager.getConnection(jdbcUrl,
properties);
Search WWH ::




Custom Search