Get Mirth Server Database name as Global Variable #5720
Replies: 1 comment
-
Thanks for the updated solution! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey, just posting an updated solution to the question posted here: https://forums.mirthproject.io/forum/mirth-connect/support/7769-get-mirth-server-database-name-as-global-variable
Original poster's question: "Is there a way I can get the Mirth database name in a global variable?
I know there is a properties file in the Mirth directory that stired the database connection string, but is there a way to get that information as a global variable in Mirth instead?"
The posted solution by agermano on April 2017 on that thread worked as late as Mirth Connect v3.8.0 (possibly later) but no longer works for Mirth Connect v4.2.0 (upgrading from v3.8.0 to v4.2.0). It appears v4.2.0 ships with org.apache.commons.configuration2, not org.apache.commons.configuration.
The new code that will work with v4.2.0:
//Start new code for v4.2.0
var builder = new org.apache.commons.configuration2.builder.fluent.Configurations();
var properties = builder.properties(new java.io.File(com.mirth.connect.server.tools.ClassPathResource.getResourceURI("mirth.properties")));
logger.info(properties.getString('database.url'));
//End new code for v4.2.0
I hope this saves somebody else some time.
Beta Was this translation helpful? Give feedback.
All reactions