Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String sharedDatabaseUrl = System.getenv("SHARED_DATABASE_URL");
- Matcher m = Pattern.compile("postgres://(.+):(.+)@(.+)/(.+)").matcher(sharedDatabaseUrl);
- if (m.matches()) {
- String postgresUser = m.group(1);
- String postgresPassword = m.group(2);
- String postgresHost = m.group(3);
- String postgresName = m.group(4);
- String jdbcUrl = String.format("jdbc:postgresql://%s/%s", postgresHost, postgresName);
- properties.setProperty(EntityManagerProperties.JDBC_USER, postgresUser);
- properties.setProperty(EntityManagerProperties.JDBC_PASSWORD, postgresPassword);
- properties.setProperty(EntityManagerProperties.JDBC_URL, jdbcUrl);
- EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnitName, properties);
Add Comment
Please, Sign In to add comment