web stats
Get Mirth Server Database name as Global Variable - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-23-2012, 09:29 AM
tfischer tfischer is offline
Mirth Newb
 
Join Date: Dec 2011
Posts: 17
tfischer is on a distinguished road
Default Get Mirth Server Database name as Global Variable

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?
Reply With Quote
  #2  
Old 08-23-2012, 09:38 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,238
cory_cole is on a distinguished road
Default

The properties file stores into a global variable. If you want to do it manually, it is globalMap.Put('variableName','value');
Reply With Quote
  #3  
Old 08-23-2012, 09:44 AM
tfischer tfischer is offline
Mirth Newb
 
Join Date: Dec 2011
Posts: 17
tfischer is on a distinguished road
Default

So the only way I can get the mirth database name would then be to the Mirth.Properties file (database.url = jdbc:jtds:sqlserver: . . . ) line and put that into the global properties?
Reply With Quote
  #4  
Old 08-23-2012, 09:51 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,238
cory_cole is on a distinguished road
Default

I believe that the Mirth properties file automatically loads into the globalMap. We have our own set of variables (depending on site) that loads as well. That file we have to run a script to load. To retrieve it, you do ...

var dbURL = globalMap.get('database.url');
Reply With Quote
  #5  
Old 08-28-2012, 02:56 PM
tfischer tfischer is offline
Mirth Newb
 
Join Date: Dec 2011
Posts: 17
tfischer is on a distinguished road
Cool

I've tried to use globalMap.get('database.url'); but it does not look like it is retrieving the database.url line from the Mirth.PROPERTIES file. I have put the code in one of my channels in the deploy script. Can anyone point me to how to sucessfully do this?
Reply With Quote
  #6  
Old 08-13-2019, 06:25 AM
ambsw ambsw is offline
Mirth Newb
 
Join Date: Aug 2014
Posts: 15
ambsw is on a distinguished road
Default

I know this is ancient, but it doesn't appear to have an answer. Rather than creating a duplicate thread to ask the same question, I'm hoping someone can answer it. (Technically I want server.url but I assume the method would be the same if it were possible.)
Reply With Quote
  #7  
Old 08-13-2019, 07:59 AM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 861
agermano is on a distinguished road
Default

This is how it's accessed in the DefaultConfigurationController.

Code:
const PropertiesConfiguration = org.apache.commons.configuration.PropertiesConfiguration;
const ClassPathResource = com.mirth.connect.server.tools.ClassPathResource;

var properties = new PropertiesConfiguration();
properties.setFile(new java.io.File(ClassPathResource.getResourceURI("mirth.properties")));
properties.load();

logger.info(properties.getString('database.url'));
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 12:23 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation