Пример #1
0
        /****************************************************************************/
        // constructors
        /****************************************************************************/

        /**
         * set up lexicon using file which contains downloaded lexAccess HSQL DB and
         * default passwords
         *
         * @param filename
         *            of HSQL DB
         */

        public NIHDBLexicon(string filename) : base()
        {
            // get rid of .data at end of filename if necessary
            var dbfilename = filename;

            if (dbfilename.endsWith(DB_HSQL_EXTENSION))
            {
                dbfilename = dbfilename.substring(0, dbfilename.length()
                                                  - DB_HSQL_EXTENSION.length());
            }

            // try to open DB and set up lexicon
            try
            {
                Class.forName(DB_HSQL_DRIVER);
                conn = DriverManager.getConnection(DB_HQSL_JDBC + dbfilename,
                                                   DB_DEFAULT_USERNAME, DB_DEFAULT_PASSWORD);
                // now set up lexical access object
                lexdb = new LexAccessApi(conn);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Cannot open lexical db: " + ex.ToString());
                // probably should thrown an exception
            }
        }
Пример #2
0
        /**
         * set up lexicon using general DB parameters; DB must be NIH specialist
         * lexicon from lexAccess
         *
         * @param driver
         * @param url
         * @param username
         * @param password
         */
        //public NIHDBLexicon(Driver driver, string url, string username, string password) : base()
        //{
        //    SetUpConnection(driver,url,username,password);
        //}

        private void SetUpConnection(string url)
        { //SQLITE
            try
            {
                conn  = new SQLiteConnection(url);
                lexdb = new LexAccessApi((SQLiteConnection)conn);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Cannot open lexical db: " + ex.ToString());
                throw;
            }
        }
Пример #3
0
        /**
         * set up lexicon using general DB parameters; DB must be NIH specialist
         * lexicon from lexAccess
         *
         * @param driver
         * @param url
         * @param username
         * @param password
         */

        public NIHDBLexicon(string driver, string url, string username,
                            string password)
        {
            // try to open DB and set up lexicon
            try
            {
                Class.forName(driver);
                conn = DriverManager.getConnection(url, username, password);
                // now set up lexical access object
                lexdb = new LexAccessApi(conn);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Cannot open lexical db: " + ex.ToString());
                // probably should thrown an exception
            }
        }