web stats
Don't wont to hardcode the database connection - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 07-13-2010, 11:25 AM
Benzo Benzo is offline
OBX.1 Kenobi
 
Join Date: May 2010
Location: Québec Canada
Posts: 35
Benzo is on a distinguished road
Smile Don't wont to hardcode the database connection

Hi All

In the first row of my filter i got this string connection

var dbConn = DatabaseConnectionFactory.createDatabaseConnection ('org.firebirdsql.jdbc.FBDriver','jdbc:firebirdsql :127.0.0.1:C:\\HDDell\\Data\\MIRTH.FDB','xyxy','xz xzxz');

Im looking for a way to not hard code the value of the connection

Is there a way to put the value in a kind of ini file and read the value of thes file ,affect a variable and use this variable in the string connection ?

What is the best way to do that.

TIA
Benzo
Reply With Quote
  #2  
Old 07-13-2010, 11:46 AM
jbartels jbartels is offline
Mirth Guru
 
Join Date: Oct 2006
Posts: 728
jbartels is on a distinguished road
Default

Sure. Just use the file reading/writing functions in JavaScript. They should be in the reference list on the right when you're working on a JS step. A preprocessor or a deploy script would be a good idea, read the file when the channel starts then save the params in the channel or global map.
__________________
Jon Bartels

Zen is hiring!!!!
http://consultzen.com/careers/
Talented healthcare IT professionals wanted. Engineers to sales to management.
Good benefits, great working environment, genuinely interesting work.
Reply With Quote
  #3  
Old 07-13-2010, 02:28 PM
mourisj mourisj is offline
Mirth Guru
 
Join Date: Feb 2007
Location: Luxembourg
Posts: 407
mourisj is an unknown quantity at this point
Default

Right, thats what we are doing (not curently for the DB connections- would be a good idea though) but for replacement tables etc.

Another way to work with variable parameters is to set up a MASTER-channel that does nothing but setting up global variables, depending on the environment. Thus, our master-channel identifies the environment, based on the servername, and sets some variables accordingly. This could also be used to set database connection data and having appropriate values in any environment.
__________________
JJ Mouris
FFE Luxembourg
IT-Department
Reply With Quote
  #4  
Old 07-13-2010, 02:44 PM
jbartels jbartels is offline
Mirth Guru
 
Join Date: Oct 2006
Posts: 728
jbartels is on a distinguished road
Default

Another advantage to the "master" channel mourisj suggests is that you can simply set these parameters in that channel rather than messing around with an external config file.
__________________
Jon Bartels

Zen is hiring!!!!
http://consultzen.com/careers/
Talented healthcare IT professionals wanted. Engineers to sales to management.
Good benefits, great working environment, genuinely interesting work.
Reply With Quote
  #5  
Old 07-14-2010, 07:39 AM
Benzo Benzo is offline
OBX.1 Kenobi
 
Join Date: May 2010
Location: Québec Canada
Posts: 35
Benzo is on a distinguished road
Default

I like this idea of a Master Chanel

I supposed i have to put the code in the deploy script of it

But how can i tell to Mirth to strat with the Master Chanel and after run the Update Data Chanel
Reply With Quote
  #6  
Old 07-14-2010, 08:09 AM
rts rts is offline
Mirth Guru
 
Join Date: Feb 2008
Posts: 215
rts is an unknown quantity at this point
Default

Another way (similar to what was previously posted) is to use the global deploy script that reads a java properties file and places the key/value pairs on the globalMap.
You can start other channels from within a channel. I had posted a thread with a topic od "Mirth APIs" a week or so ago that shows how to control channels and read java property files pushing values to the map
http://www.mirthcorp.com/community/f...ead.php?t=4090
Reply With Quote
  #7  
Old 07-14-2010, 12:05 PM
Benzo Benzo is offline
OBX.1 Kenobi
 
Join Date: May 2010
Location: Québec Canada
Posts: 35
Benzo is on a distinguished road
Default

Hi rts
I have taken a part of the code of these threrad

http://www.mirthcorp.com/community/f...ead.php?t=4090

Code:
var channelCont = Packages.com.webreach.mirth.server.controllers.Cha.nnelController.getInstance();
var channelID = channelCont.getChannelId("Update Data");
var channelStaCont = Packges.com.webreach.mirth.server.controllers.Cha.nnelStatusController.getInstance();
channelStaCont.stratChanel(channelID);
I put this code in the deploy scripts of my Master Chanel thinking it will start the Update Data Chanel.

Is it ok to do it like this ?




Benzo
Reply With Quote
  #8  
Old 07-14-2010, 12:10 PM
rts rts is offline
Mirth Guru
 
Join Date: Feb 2008
Posts: 215
rts is an unknown quantity at this point
Default

I have never put that code in a deploy script, not sure if it will run. What I have done is used that code in a transformer. Did you paste that code to the formum because there are errors in it:

var channelCont = Packages.com.webreach.mirth.server.controllers.Cha nnelController.getInstance();
var channelID = channelCont.getChannelId("Update Data");
var channelStaCont = Packges.com.webreach.mirth.server.controllers.Chan nelStatusController.getInstance();
channelStaCont.startChanel(channelID);

I see that ChannelController displays as "Cha nnel" There should not be a space there
Reply With Quote
  #9  
Old 07-14-2010, 12:24 PM
Benzo Benzo is offline
OBX.1 Kenobi
 
Join Date: May 2010
Location: Québec Canada
Posts: 35
Benzo is on a distinguished road
Default

No i paste the code just to be clear
sorry for the "Cha nnel " i have made a error when typing it
Reply With Quote
  #10  
Old 07-14-2010, 12:26 PM
mourisj mourisj is offline
Mirth Guru
 
Join Date: Feb 2007
Location: Luxembourg
Posts: 407
mourisj is an unknown quantity at this point
Default

Quote:
Originally Posted by Benzo View Post
I like this idea of a Master Chanel
Me too LOL !! Of course, the idea was mine on our site ...

Quote:
I supposed i have to put the code in the deploy script of it
Yes, that's the way we do.
For the rest, the channel is just a Javascript Reader on the source side and Javascript writer as a destination.

The code on both ends is quite complex:

Code:
return;
(As it needs to execute, it executes once a day. We have no performance issues ... )


But how can i tell to Mirth to strat with the Master Chanel and after run the Update Data Chanel
__________________
JJ Mouris
FFE Luxembourg
IT-Department

Last edited by mourisj; 07-14-2010 at 12:28 PM.
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 02:40 AM.


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