How to configure DB via an environment variable?

Asked

Viewed 91 times

1

I have a multi-client JSP application.
Currently the database configuration is in a file variable.propriet, and obtain through the method

private static String getUrlBanco() {        
    ResourceBundle b = ResourceBundle.getBundle("Base.variavel");
    return b.getString("urlbanco");
}

The problem is that it is not standard, the location of the base and the file is compressed along with War, which forces me to generate a War per client.

I wanted a way that this was set outside the application, I don’t know, by environment variable, by configuration in Tomcat...
I accept suggestions.

  • 1

    Consider using a JNDI entry in Tomcat. Then you map and consume on web.xml. So, you just need to restart your application,

  • Ai the user and password of the bank would be "accessible" to the users

  • 1

    The Tomcat and OS administrator, probably yes, for the application users would not be. Also, you can encrypt the password when mapping password as JNDI input in Tomcat.

  • How do I map the encrypted password?

  • Could you better contextualize this? Who is responsible for the database, the client or you? Why doesn’t the bank have a default place? You say access data is inside WAR in a text file. You think this is safe?

  • Who is responsible for the database? good question. Customers are responsible for DB, but they do not have the user and password(company policy)(he who has to do maintenance, but can not have access).

  • Why the bank doesn’t have a standard place? pq are prefectures, and each one has a different default from where the bank is. most of the database is on a different Tomcat Server

  • You say access data is inside WAR in a text file. You think this is safe? only the location of the database, user and password is inside a . java

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.