Announcement

Collapse
No announcement yet.

Using Oracle TNS in the server manager connection string

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using Oracle TNS in the server manager connection string

    Hi,

    I have successfully connected to an oracle DB from my channels using a TNS names connection.

    I have also connected the Mirth Connect backend to the oracle database with a standard JDBC connection string.
    Code:
    jdbc:oracle:thin:@servername:1521:dbname
    However I would like to be able to connect the server manager using a TNS names connection string as I do in my channels but am unable to.

    In order to get a TNS connection to work in my channels I had to set the following property before making the connection.

    Code:
    Packages.java.lang.System.setProperty("oracle.net.tns_admin", "C:\path to tnsnames.ora");
    
    var dbConnection = DatabaseConnectionFactory.createDatabaseConnection("oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@CON_FROM_TNSNAMES", "user", "pass");
    I cant see a way to add this property globally or before the connection of the server manager is attempted.

    Thanks in advance for your help.

    Using Mirth Connect Server 3.2.1.7650

  • #2
    Thought I would post a solution to my own post in case it helps anyone in the future.

    (This was probably obvious to anyone who has used Java a lot but was not to me at the time.)

    The full TNS connection string can be added as the jdbc url as it would be found in the tnsnames.ora file.

    For example in your tnsnames.ora file you would have the following (or similar for your setup)

    Code:
    MY_TNS_NAME
    (
      DESCRIPTION =
      (CONNECT_TIMEOUT=2)
      (RETRY_COUNT=10)
      (LOAD_BALANCE = on)
      (ADDRESS = (PROTOCOL = TCP)(HOST = server1)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = server2)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = server3)(PORT = 1521))
      (CONNECT_DATA =
        (SERVICE_NAME = MYSID)
      )
    )
    So in mirth server manager / config file the jdbc url would be:
    Code:
    jdbc:oracle:thin:@(   DESCRIPTION =   (CONNECT_TIMEOUT=2)   (RETRY_COUNT=10)   (LOAD_BALANCE = on)   (ADDRESS = (PROTOCOL = TCP)(HOST = server1)(PORT = 1521))   (ADDRESS = (PROTOCOL = TCP)(HOST = server2)(PORT = 1521))   (ADDRESS = (PROTOCOL = TCP)(HOST = server3)(PORT = 1521))   (CONNECT_DATA =     (SERVICE_NAME = MYSID)   ) )
    Hope this helps.

    Thanks
    Last edited by swiftnano; 07-03-2018, 06:53 AM.

    Comment

    Working...
    X