Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7411627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:24:56+00:00 2026-05-29T06:24:56+00:00

I want to set the database connection at run time for my Play project.

  • 0

I want to set the database connection at run time for my Play project. I know that I can set a property run time with the following code:

@OnApplicationStart public class Bootstrap extends Job
{
   @Override public void doJob()
   {
     // now set the values in the properties file
     Play.configuration.setProperty("db.driver", dbDriver);
     Play.configuration.setProperty("db.url", dbUrl);
     Play.configuration.setProperty("db.user", dbUsername);
     Play.configuration.setProperty("db.pass", dbPassword);
   }
}

But when executing the code above the file is not actually changed, I think just in memory.

How can I set the database properties and force Play! to use this properties in order to connect to the right database onApplicationStart?

Thanks!

UPDATE 2012-01-29

Solution is possible via a plugin. In this plugin I have to override onConfigurationRead() and apply the properties to the configuration file at that moment. I will try to post some code as soon as I have time for this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:24:56+00:00Added an answer on May 29, 2026 at 6:24 am

    By the time you change the properties, the DB plugin is already initialized. You need to write a plugin and overwrite the onConfigurationRead() method, then put your new settings there. Paly’s dbplugin will init later on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a vector<set<char> > data structure (transactions database) and I want to know
I am working with SQL Server and I want to set the Database password
I want to store a large result set from database in memory. Every record
I want to retrieve a set of records from a database, do a rs.next()
I want to set something up so that if an Account within my app
I want to prevent database connection being open as much as possible, because this
I want to do some sql code run in my webservice in c# The
Summary: I want to be able to run a query against an external database
Consider a simple app server / database server setup. You want to set some
I'd like to dry-run Hibernate HQL queries. That is I'd like to know what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.