Why do I receive an error when trying to insert records to an Access database using two parallel running instances of MATLAB?

2 views (last 30 days)
I am getting the following error when trying to insert records to an Access database using two parallel running instances of MATLAB:
??? Java exception occurred:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Could not read; currently locked by user 'admin' on machine 'XYZ'.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(Unknown Source)
Error in ==> database.fastinsert at 184
StatementObject.execute;

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 2 Jan 2020
Edited: MathWorks Support Team on 26 Aug 2020
Using FASTINSERT to insert records to the same table in the same Microsoft Access database using two parallel running instances of MATLAB should work.
The most likely cause for this error is that the database might be open exclusively for editing by another user:
Another possible cause is the use of "referential integrity": if you set referential integrity while using transactions, it could throw the mentioned error. An SQL Server database, for example, does not have this problem, but MS Access does. Removing the "enforce referential integrity" feature could solve this problem.
The Database Toolbox does not support explicitly setting the locking mechanism to be used. More information about lock types can be found here:
If problems persist, the Tracing feature of the ODBC console can be used to try to find the cause of the problem. Another possibility is to implement the database access manually through ADODB (actxserver, Windows only).

More Answers (0)

Products


Release

R2007b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!