Is there a way to dynamically change the connection to the database by changing the standalone.xml file of Wildfly 8 (or 10) ? Currently I have a HibernateSessionFactory class that creates a m EntityManagerFactory with the connection parameters from a .properties file:
try {
Map<String, String> parametros = new HashMap<String, String>();
String valor = "jdbc:sqlserver:" + pGetServer()
+ ";databaseName=%s";
parametros.put(PERSISTENCE, String.format(valor, pGetDataBase()));
entityManagerFactory = Persistence.createEntityManagerFactory(
"BANCO", parametros);
} catch (Exception e) {
System.err.println("%%%% Error Creating entityManagerFactory %%%%");
e.printStackTrace();
}
persistence.xml :
<properties>
<property name="javax.persistence.jdbc.driver"
value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="javax.persistence.jdbc.user" value="user" />
<property name="javax.persistence.jdbc.password" value="pass" />
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.cache.provider_class"
value="org.hibernate.cache.SingletonEhCacheProvider" />
</properties>