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

5 次查看(过去 30 天)
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