No announcement yet.

No connection to Caché database

  • Filter
  • Time
  • Show
Clear All
new posts

  • No connection to Caché database

    Hi @all

    After upgrading from 3.4.2 we are now using Mirth 3.7.1 on Ubuntu 18.04. All 309 channels except one are working fine. The one that did not work collects data from a Intersys Caché database.

    What we did:
    • put the two JDBS jars "cache-db-2.0.0.jar" and "cache-jdbc-2.0.0.jar" in folder custom-lib
    • add the following line to dbdrivers.xml
    • Code:
      <driver class="com.intersys.jdbc.CacheDriver" name="Cache" template="jdbc:Cache://host:port/namespace" selectLimit="" />
    • restart mirth without errors
    • create a new channel with database reader as source and fill in the data for Driver, Username and Password
    • click on "Select/Get Tables" creates the error "...Caused by: java.lang.NoClassDefFoundError: java/sql/Driver..."
    • changed source connector to "Javascript Reader" and put in the following code (of cause with the correct data)
    • Code:
      var dbConn;
      var result;
      try {
      	dbConn = DatabaseConnectionFactory.createDatabaseConnection('com.intersys.jdbc.CacheDriver','jdbc:Cache://ip:port/namespace','username','password');
      	result = dbConn.executeCachedQuery(query);
      } finally {
      	if (dbConn) { dbConn.close();	}
    • and we got the same error: "JavaScriptExecutorException: java.lang.NoClassDefFoundError: java/sql/Driver"
    • At last I wrote following piece of code that creates no error
    • Code:
      var info = new java.util.Properties();
      info.put("user", "username");
      info.put("password", "password");
      var driver1 = new com.mirth.connect.connectors.jdbc.CustomDriver(java.lang.Thread.currentThread().getContextClassLoader(), 'com.intersys.jdbc.CacheDriver');
      driver1.connect('jdbc:Cache://ip:port/namespace', info);
      logger.debug("Cache Treiber acceptsURL: " + driver1.acceptsURL('jdbc:Cache://ip:port/namespace') );
      logger.debug("Cache Driver jdbcCompliant: " + driver1.jdbcCompliant() );
      logger.debug("Cache Driver getMinorVersion: " + driver1.getMinorVersion() );
      logger.debug("Cache Driver getMajorVersion: " + driver1.getMajorVersion() );
    • The output was correct - so I think the driver is loadable

    So what can we do to connect to Caché? Is there an other way to establish a connection?


  • #2
    It smells like a classloader issue. Can you try dropping your jar files into server-lib/database instead of custom-lib to see if that gives a different result?

    custom-lib is really supposed to be deprecated, and you should use named resource directories to assign jar resources only to the channels that need them.


    • #3
      Thanks for your suggestion. I just tried both and unfortunately I got the same errors. But I found a solution in the Caché support:
      var driver = new com.mirth.connect.connectors.jdbc.CustomDriver(java.lang.Thread.currentThread().getContextClassLoader(), 'com.intersys.jdbc.CacheDriver');
      dbconn = new com.mirth.connect.server.userutil.DatabaseConnection(driver, new java.lang.String($cfg('dbConnCache') + "/::false?username=" + $cfg('dbCacheUser') + "&password=" + $cfg('dbCachePwd')));
      Adding username and password to the connection string instead of using java.util.Properties did the trick and I can use "dbconn" as usual.

      I don't like to use Mirth classes in connectors because of possible issues after upgrades but for today I found no other solution.

      That custom-lib is really supposed to be deprecated is brand new for me. Thanks for the tip.


      • #4
        com.mirth.connect.server.userutil.DatabaseConnecti on is in the User API javadoc, so you shouldn't have to worry

        I think because of this, you should be able to skip the package name and just do:

        dbconn = new DatabaseConnection(driver, new java.lang.String($cfg('dbConnCache') + "/::false?username=" + $cfg('dbCacheUser') + "&password=" + $cfg('dbCachePwd')));