Exemple #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 + ":");
     }
 }
Exemple #2
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);
     }
 }