Error while executing 'onCleanup' class destructor with sqlwrite() to PostgreSQL

조회 수: 11 (최근 30일)
Tim
Tim 2025년 3월 10일
답변: Tim 2025년 3월 11일
Hello Friends,
i am using sqlwrite() in a Matlab App.
% csvDataToImport is a table
sqlwrite(app.conn, 'my_SQLTable', csvDataToImport)
The connection works fine.
The connection is open until the App is closed than the connection gets closed "close(app.conn)".
However when this line is executed i get following error.
Warning: The following error was caught while executing 'onCleanup' class destructor:
Error using database.jdbc.connection/sqlwriteHook>@()close(metaStmt)
Java exception occurred:
java.lang.ClassCastException
at
java.util.concurrent.atomic.AtomicIntegerFieldUpdater$AtomicIntegerFieldUpdaterImpl.throwAccessCheckException(AtomicIntegerFieldUpdater.java:475)
at
java.util.concurrent.atomic.AtomicIntegerFieldUpdater$AtomicIntegerFieldUpdaterImpl.accessCheck(AtomicIntegerFieldUpdater.java:466)
at
java.util.concurrent.atomic.AtomicIntegerFieldUpdater$AtomicIntegerFieldUpdaterImpl.compareAndSet(AtomicIntegerFieldUpdater.java:488)
at org.postgresql.jdbc.PgStatement.close(PgStatement.java:679)
Error in onCleanup/delete (line 25)
obj.task();
Error in database.jdbc.connection/sqlwriteHook (line 22)
c = onCleanup(@()closeStatement(insertStmt));
Error in database.relational.connection/sqlwrite (line 187)
sqlwriteHook(conn,tablename,data,columnnames,newTableCreated)
It still works (csvDataToImport is written in the PostgreSQL Databank).
I am using the newest JDBC driver and do not have problems with other commands like exec() or fetch().
How do i fix this error?
Thank you a lot for heling me!

채택된 답변

Tim
Tim 2025년 3월 11일
If anybody else has this problem:
Do not use
javaaddpath(jdbcPath);
use JDBCDriverLocation instead.
app.conn = database(datenbankName, username, password, ...
'Vendor', 'PostgreSQL', 'Server', Server, 'PortNumber', PortNumber,...
'JDBCDriverLocation', jdbcPath);
This will fix your problem.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by