Advertisement
Guest User

Untitled

a guest
Jan 26th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. try {
  2. URI dbUri = new URI(databaseUrl);
  3. String username = dbUri.getUserInfo().split(":")[0];
  4. String password = dbUri.getUserInfo().split(":")[1];
  5. String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + dbUri.getPath() + "?user=" + username + "&password="+password+PARAMS;
  6. databaseConnection = DriverManager.getConnection(dbUrl);
  7. }
  8. catch (SQLException | URISyntaxException e) {
  9. //e.printStackTrace();
  10. System.out.println("Failed connecting to database");
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement