这是我的示例代码:
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:锁获取超时:PhantomReadLock[write.lock/tttable]”------------
我找不到代码有什么问题。可能是jar兼容性问题。
我无法获得 IndexWriter 对象。