Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
Expand all | Collapse all

Use UCanAccess to connect MS Access database

  • 1.  Use UCanAccess to connect MS Access database

    Posted Fri December 06, 2019 09:53 AM

    Originally posted by: qtbgo


    Hi, I want to use an open source jdbc driver to connect to MS access database in OPL. Here is what I have done.

    1 unzip all ucanaccess file to my opl project folder.

    2 in opl dat file :

    prepare {
        includeScript("jdbc.js");

          // Create the jdbc custom data source
        var db = JDBCConnector("jdbc:ucanaccess://D:/pythonOptimizationExample/IBMDecisionOptimization/OPL-jdbc-data-source/examples/studio_integration/oil.accdb;openExclusive=true;ignoreCase=true");
        
        // input data
          db.read("Gasolines", "SELECT NAME FROM GASDATA");
          db.read("Oils", "SELECT NAME FROM OILDATA");
          db.read("GasData", "SELECT * FROM GASDATA");
          db.read("OilData", "SELECT * FROM OILDATA");

    }

    3 in "jdbc.js :


    // EDIT: you want to change this for your actual driver
    var jdbc_driver = "ucanaccess-4.0.4.jar"
    // EDIT: specify where to look for the jdbc driver. Default is in . (besides this .js script) and in ../../external_libs
    var jdbc_driver_path = ".;../../external_libs"


    // EDIT: specfify where jdbc-custom-data-source is of the github project.
    // default is to look in . and ../../lib
    var libs = ".;../../lib";
     

    But it doesn't work. Could someone tell me how to do it?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Use UCanAccess to connect MS Access database

    Posted Sat December 07, 2019 06:29 AM

    Originally posted by: qtbgo


    This is according to an example by IBM . In the IBM example,  it uses MS sql server seeing below. What I want is to use MS Access. Any idea?

    prepare {
      includeScript("jdbc.js");
       
      // Create the jdbc custom data source
      var db = JDBCConnector("jdbc:sqlserver://localhost;instanceName=SQLEXPRESS;databaseName=custom_data_source;integratedSecurity=true");
       
      // input data
      db.read("Gasolines", "SELECT NAME FROM GASDATA");

    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Use UCanAccess to connect MS Access database

    Posted Thu January 02, 2020 05:48 PM

    Originally posted by: Viu-Long Kong


    Hi.

     

    What error message do you get?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Use UCanAccess to connect MS Access database

    Posted Tue January 07, 2020 03:22 AM

    Originally posted by: Chabrier Alain


    Can you please add some information on your ticket in https://github.com/IBMDecisionOptimization/OPL-jdbc-data-source/issues/1 so that we can answer your question?

     

    thanks.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer