Example #1
0
        public static Boolean TestConnection(String driver, String connectionString, String username, String password, out String errormessage)
        {
            Boolean success = false;

            errormessage = null;
            try
            {
                IMojoHiveDriver hivedriver = CreateCustomDriver(driver);
                String          queue      = ""; // The queue is actually part of the connection string (url) so we pass a blank.
                int             result     = hivedriver.TestConnection(driver, connectionString, queue, username, password);

                if (result == 0)
                {
                    success = true;
                }
                else
                {
                    errormessage = hivedriver.GetLastExceptionMessage();
                }
            }
            catch (System.Exception ex)
            {
                Debug.WriteLine("Error in TestConnection(): " + ex.Message);

                //throw ex;
            }
            return(success);
        }
Example #2
0
        public static int RunBigDataQueryJava(String dataPipePath, String connectionString, String sql)
        {
            int result = 0;

            _logger.LogMsg(Level.Debug, "Enter function RunBigDataQueryJava().");

            try
            {
                // The queue name is not necessary as a separate parameter. it is part of the URL.
                // TO DO: change Java interface so we don't need to pass this parameter at all.
                String unused_queue_name = "";

                // Create Java proxy
                IMojoHiveDriver driver = CreateCustomDriver(_driverName);

                if (!Properties.Settings.Default.SimulateQuery)
                {
                    // Run the real query via Java / JDBC.
                    _logger.LogMsg(Level.Debug, "Calling Java method QueryResultSetToPipe().");

                    result = driver.QueryResultSetToPipe(_driverName, _connectionString, unused_queue_name, _userName, _password, _sql, _dataPipePath);

                    _logger.LogMsg(Level.Debug, "Return from Java method QueryResultSetToPipe(). Result = " + result.ToString());
                    // DEBUGGING: just write a fixed data file to the pipe instead of running an actual JDBC query.
                }
                else
                {
                    // Load the data from a local data file instead.
                    String data_file = "";
                    if (File.Exists(Properties.Settings.Default.TestDataFilename))
                    {
                        data_file = Properties.Settings.Default.TestDataFilename;
                    }
                    else
                    {
                        String local_path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                        data_file = Path.Combine(local_path, Properties.Settings.Default.TestDataFilename);
                    }
                    if (File.Exists(data_file))
                    {
                        _logger.LogMsg(Level.Debug, String.Format("Calling Java method TestNamedPipeWrite() with input data file {0}.", data_file));
                        result = driver.TestNamedPipeWrite(dataPipePath, data_file);
                        _logger.LogMsg(Level.Debug, "Return from Java method TestNamedPipeWrite(). Result = " + result.ToString());
                    }
                    else
                    {
                        _logger.LogMsg(Level.Error, String.Format("Test data file not found: {0}", Properties.Settings.Default.TestDataFilename));
                    }

                    // TO DO: If we can't run the test, do we still have to close the data pipe?
                }

                if (driver.GetLastErrorCode() != 0)
                {
                    _logger.LogMsg(Level.Error, String.Format("Exception from MojoHiveDriver: {0}.", driver.GetLastExceptionMessage()));
                }
            }
            catch (Exception ex)
            {
                _logger.LogMsg(Level.Fatal, "Unexpected error in RunBigDataQueryJava(): " + ex.Message);
            }


            return(result);
        }