这是我的示例代码:
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setUser("root");
dataSource.setPassword("ncl");
dataSource.setDatabaseName("userdb");
dataSource.setEmulateLocators(true); //This is important because we are dealing with a blob type data field
try{
JdbcDirectory jdbcDir = new JdbcDirectory(dataSource, new MySQLDialect(), "tttable");
StandardAnalyzer analyzer = new StandardAnalyzer();
IndexWriter writer = new IndexWriter(jdbcDir, analyzer,false);
writer.optimize();
writer.close();
}catch(Exception e){
System.out.print(e);
}
我卡在这一行: IndexWriter writer = new IndexWriter(jdbcDir,analyzer,false);
每当我尝试运行这段代码时,我都会收到以下异常:
------"org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: PhantomReadLock[write.lock/tttable]"------------
我无法找出代码的问题。可能是它与JAR相容性的问题。
我无法获得IndexWriter对象。