Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Help with datasource configuration in main class


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();

        "DBURI ["+dbUri+"]");"Username ["+username+"]");"Password ["+password+"]");"Host ["+dbUri.getHost()+"]");"Port ["+dbUri.getPort()+"]");"Path ["+dbUri.getPath()+"]");

        "DBRUL ["+dbUrl+"]");


        PGSimpleDataSource pgDS = new PGSimpleDataSource();







        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

Back to the top