bugfixes for new compilation, particularly with Lucene 1.3-final

This commit is contained in:
Eric J. Bowersox 2004-03-08 05:53:52 +00:00
parent 8514d152f1
commit c2552a9e70
4 changed files with 58 additions and 1 deletions

2
drivers/.gitignore vendored
View File

@ -1 +1 @@
mysql-connector-java-3.0.7-stable-bin.jar
mysql-connector-*.jar

View File

@ -86,6 +86,22 @@ class IndexDirectoryImpl extends Directory
} // end release
public boolean isLocked()
{
try
{ // call through to the database
return m_ops.queryLock(m_ndx,m_name);
} // end try
catch (DatabaseException e)
{ // turn it into an I/O exception
logger.warn("IndexDirectoryImpl.MyLock.isLocked(): failed operation",e);
return false;
} // end catch
} // end isLocked
} // end class MyLock
/*--------------------------------------------------------------------------------

View File

@ -64,6 +64,8 @@ abstract class IndexOps extends OpsBase
abstract void releaseLock(int ndx, String lock) throws DatabaseException;
abstract boolean queryLock(int ndx, String lock) throws DatabaseException;
abstract void releaseAllLocks(int ndx) throws DatabaseException;
} // end class IndexOps

View File

@ -538,6 +538,45 @@ class IndexOps_mysql extends IndexOps
} // end releaseLock
boolean queryLock(int ndx, String lock) throws DatabaseException
{
Connection conn = null;
PreparedStatement stmt = null;
Statement stmt2 = null;
ResultSet rs = null;
try
{ // get a connection
conn = getConnection();
// lock the table
stmt2 = conn.createStatement();
stmt2.executeUpdate("LOCK TABLES ndx_locks READ;");
// see if the lock is present
stmt = conn.prepareStatement("SELECT ndxid FROM ndx_locks WHERE ndxid = ? AND name = ?;");
stmt.setInt(1,ndx);
stmt.setString(2,lock);
rs = stmt.executeQuery();
return rs.next(); // present if true
} // end try
catch (SQLException e)
{ // translate to a general DatabaseException
throw generalException(e);
} // end catch
finally
{ // shut everything down
MySQLUtils.unlockTables(conn);
SQLUtils.shutdown(rs);
SQLUtils.shutdown(stmt);
SQLUtils.shutdown(stmt2);
SQLUtils.shutdown(conn);
} // end finally
} // end queryLock
void releaseAllLocks(int ndx) throws DatabaseException
{
Connection conn = null;