This is my sample code:
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);
}
I am stuck at this line: IndexWriter writer = new IndexWriter(jdbcDir, analyzer,false);
Everytime I try to run this code, I receive the following exception:
------"org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: PhantomReadLock[write.lock/tttable]"------------
I cannot find what is wrong with the code. It may be it is a jar compatibility issue.
I am unable to get an IndexWriter object.