Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do i avoid this exception

 
chinomso ikwuagwu
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tableOne and tableTwo are temporary tables which i need to delete from the database.
However the method createTable throws an exception @ line 7 and the tables don't get
deleted. Details of the exception thrown are attached...

Note:
Both tableOne and tableTwo hold references to the same Connection 'con'.




1 public JDBCAdapter createTable(Connection con, String name1, String name2, String newTableName) throws SQLException {

2 JDBCAdapter tableOne = this.createDBTable(con, "SELECT * FROM [" + name1 + "]");

3 JDBCAdapter tableTwo = this.createDBTable(con, "SELECT * FROM [" + name2 + "]");

4 JDBCAdapter returnVal = createAgreedTable(con, tableOne, tableTwo, newTableName);

5 try {

6 Statement s = tableOne.getConnection().createStatement();

7 s.executeUpdate("DROP TABLE [" + tableOne.getName() + "]");

8 s.executeUpdate("DROP TABLE [" + tableTwo.getName() + "]");

9 }catch(SQLException se) {

10se.printStackTrace();

11 }

12 setAdapter(returnVal);

13 return returnVal;

14 }


Exception Thrown at line 10 reads...

sun.jdbc.odbc.JdbcOdbcBatchUpdateException: [Microsoft][ODBC Microsoft Access Driver] The database engine could not lock table 'DISTINCT113' because it is already in use by another person or process.at sun.jdbc.odbc.JdbcOdbcStatement.emulateBatchUpdate(JdbcOdbcStatement.java:1020)at sun.jdbc.odbc.JdbcOdbcStatement.executeBatchUpdate(JdbcOdbcStatement.java:878)at sun.jdbc.odbc.JdbcOdbcStatement.executeBatch(JdbcOdbcStatement.java:862)
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Close your Database (design mode of Microsoft Access)and then try to modify it.

This error will occur

[Vendor][ODBC Driver] The database engine could not lock table 'TableName' because it is already in use by another person or process.


when your database is open for editing and you try to modify it.
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can retrieves the update count for each update statement in the batch update that executed successfully before this exception occurred through getUpdateCounts Mehtod of BatchUpdateException class.

for more information see Java Doc BatchUpdateException

or you can go for these steps to retrieving information from a BatchUpdateException Steps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic