Java – should data sources be defined in the application or application server?
I have developed applications for two different teams (running on the JBoss server) One team has a data source configuration inside the application war file, and the other team has a data source configuration inside the application server's standalone XML I don't know which method is better
So I'm on the server's standalone Some advantages are found when defining data sources in XML
>On the server's standalone Defining data sources in XML is more secure than war files If the server's standalone The database connection credentials stored in XML are almost never modified, so the password in the war file is usually transferred from the developer's machine to the server and database configuration, which is a secure computer propagated by all developers. > Through the standard With data sources in XML, we can make the war file smaller because the jdbc driver can be installed as a module and can be deleted from the war file In addition, loading JDBC as a module is more effective than classpath. > If we don't want the application development team to understand the database connection settings, we can put the data source in standalone XML
By getting the data source configuration in the application war file, I see the following advantages:
>The development team does not have permission to change the JBoss configuration file in the JBoss running environment Therefore, DB connection can only be defined in the application. > In the development state, developers often need to switch between different database connections, which is very useful For example, a developer can specify a connection when building a war file
So I wonder if the two methods have other advantages In your opinion, which method is better?
Solution
In addition to the problems mentioned in the question, another advantage of having the data source outside the application is that it allows the same war file to be used in different regions This will allow the team to provide different databases for different environments (such as test, perf and prod) when using the same war file
You can make a deployment, and then the war files tested by the QA team can be upgraded to the production area This will ensure that no untested code enters higher areas, while avoiding the need for SCM branches and code freezing