5
Is there any way to dynamically change the connection to the database by changing the file standalone.xml of Wildfly 8 (or 10)? Currently I have a class Hibernatesessionfactory that creates um Entitymanagerfactory with connection parameters from a file .properties:
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>
Post your . properties, think you can read the file dynamically. It’s change your connection. In which situation you want to change your connection.
– LR10
That’s the point. I already got the connection from there. The idea is not to get the connection information from there, but from Wildfly’s standalone.xml file.
– Ronie M