Example #1
0
 public virtual void initialize(string paramString, Properties paramProperties, SearchFactoryImplementor paramSearchFactoryImplementor)
 {
     this.tableName = directoryProviderNameToTableName(paramString);
     try
     {
         this.dialect    = (Dialect)Type.GetType(paramProperties.getProperty("jdbc_driver")).forName(paramProperties.getProperty("jdbc_dialect")).newInstance();
         this.dataSource = new JDBCDirectoryDatasource(paramProperties.getProperty("jdbc_url"), paramProperties.getProperty("jdbc_username"), paramProperties.getProperty("jdbc_password"), paramProperties.getProperty("jdbc_dialect"));
         this.directory  = new JdbcDirectory(this.dataSource, this.dialect, this.tableName);
         try
         {
             this.dataSource.Connection.prepareStatement("SELECT COUNT(*) FROM " + this.tableName).execute();
         }
         catch (SQLException sQLException)
         {
             Console.WriteLine("Creating and Initializing Table: " + this.tableName + " for the First Time " + sQLException.Message);
             this.directory.create();
             IndexWriter indexWriter = new IndexWriter(this.directory, AnalyzerFinder.LocaleAnalyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);
             indexWriter.UseCompoundFile = false;
             indexWriter.optimize();
             indexWriter.close();
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception.ToString());
         Console.Write(exception.StackTrace);
         throw new System.ArgumentException("Error when initalizing directory provider: " + exception.Message + ":");
     }
 }
Example #2
0
        public virtual void initialize(string paramString, Properties paramProperties, SearchFactoryImplementor paramSearchFactoryImplementor)
        {
            this.tableName = directoryProviderNameToTableName(paramString);
            string str1 = paramProperties.getProperty("jdbc_dialect");
            string str2 = paramProperties.getProperty("jdbc_driver");
            string str3 = paramProperties.getProperty("jdbc_url");

            if (str1.IndexOf("MySQL", StringComparison.Ordinal) != -1)
            {
                str3 = str3 + "?emulateLocators=true";
            }
            try
            {
                this.dialect    = (Dialect)Type.GetType(str2).forName(str1).newInstance();
                this.dataSource = new RemoteDBDirectoryDatasource(str3, paramProperties.getProperty("jdbc_username"), paramProperties.getProperty("jdbc_password"), paramProperties.getProperty("jdbc_dialect"));
                this.directory  = new JdbcDirectory(this.dataSource, this.dialect, this.tableName);
                try
                {
                    this.dataSource.Connection.prepareStatement("SELECT COUNT(*) FROM " + this.tableName).execute();
                }
                catch (SQLException)
                {
                    this.directory.create();
                    IndexWriter indexWriter = new IndexWriter(this.directory, AnalyzerFinder.LocaleAnalyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);
                    indexWriter.UseCompoundFile = false;
                    indexWriter.optimize();
                    indexWriter.close();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.ToString());
                Console.Write(exception.StackTrace);
            }
        }
Example #3
0
 public virtual void initialize(string paramString, Properties paramProperties, SearchFactoryImplementor paramSearchFactoryImplementor)
 {
     this.tableName = directoryProviderNameToTableName(paramString);
     try
     {
         this.dialect    = (Dialect)Type.GetType(paramProperties.getProperty("jdbc_driver")).forName(paramProperties.getProperty("jdbc_dialect")).newInstance();
         this.dataSource = new JDBCDirectoryDatasource(paramProperties.getProperty("jdbc_url"), paramProperties.getProperty("jdbc_username"), paramProperties.getProperty("jdbc_password"), paramProperties.getProperty("jdbc_dialect"));
         this.directory  = new JdbcDirectory(this.dataSource, this.dialect, this.tableName);
         try
         {
             this.dataSource.Connection.prepareStatement("SELECT COUNT(*) FROM " + this.tableName).execute();
         }
         catch (SQLException)
         {
             Console.WriteLine("Creating and Initializing Table: " + this.tableName + " for the First Time");
             this.directory.create();
             IndexWriter indexWriter = new IndexWriter(this.directory, new ClassicAnalyzer(Version.LUCENE_22), true, IndexWriter.MaxFieldLength.UNLIMITED);
             indexWriter.close();
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception.ToString());
         Console.Write(exception.StackTrace);
     }
 }