Hi,

I am trying to run embedded Jetty for Heroku deployment. Have configured a
datasource using jetty-env.xml in the web app but I want to apply database
url from environment string stored in my heroku app environment.

I am trying this in my Main class .. but I am not sure if this is correct
or how I apply this Resource object to the WebAppContext?

//configure database properties

        URI dbUri = new URI(System.getenv("DATABASE_URL"));


        String username = dbUri.getUserInfo().split(":")[0];

        String password = dbUri.getUserInfo().split(":")[1];

        String dbUrl = "jdbc:postgresql://" + dbUri.getHost() + ':' +
dbUri.getPort() + "/" + dbUri.getPath();



        logger.info("DBURI ["+dbUri+"]");

        logger.info("Username ["+username+"]");

        logger.info("Password ["+password+"]");

        logger.info("Host ["+dbUri.getHost()+"]");

        logger.info("Port ["+dbUri.getPort()+"]");

        logger.info("Path ["+dbUri.getPath()+"]");



        logger.info("DBRUL ["+dbUrl+"]");



        PGSimpleDataSource pgDS = new PGSimpleDataSource();

        pgDS.setDatabaseName(dbUri.getPath());

        pgDS.setUser(username);

        pgDS.setPassword(password);

        pgDS.setServerName(dbUri.getHost());

        pgDS.setPortNumber(dbUri.getPort());



        Resource resource = new Resource("jdbc/obmDS", pgDS);

-- 
"A computer lets you make more mistakes faster than any other invention in
human history, with the possible exceptions of handguns and tequila."
- Mitch Ratcliffe
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to