简体   繁体   English

SAP Hana 中 JDBC 的 SQL 更新不是持久的

[英]SQL UPDATE over JDBC in SAP Hana is not persistent

We are currently migrating from Oracle to SAP Hana, and we are using Java-programs that access the database via JDBC.我们目前正在从 Oracle 迁移到 SAP Hana,我们正在使用通过 JDBC 访问数据库的 Java 程序。

When I do a SQL-update to the Hana database in Java, this change is not written to the database.当我对 Java 中的 Hana 数据库进行 SQL 更新时,此更改不会写入数据库。

After the update, I use Squirrel to check whether the table has been changed and the change is not visible!更新后我用Squirrel查看表是否有变化,变化是不可见的!

How can I write data with UPDATE, INSERT and DELETE in Hana via JDBC?如何通过 JDBC 在 Hana 中使用 UPDATE、INSERT 和 DELETE 写入数据?

As SipCat found out himself, this behavior is caused by正如 SipCat 自己发现的那样,这种行为是由

  • using autocommit=false使用autocommit=false
  • and NOT COMMIT ing the changes made by the application.并且 NOT COMMIT应用程序所做的更改。

In this situation, the transaction will be rolled back when the application disconnects the DB session.在这种情况下,当应用程序断开 DB session 时,事务将回滚。

Several SQL Editor/Query UI tools (like DBSquirrel) use autocommit=true or automatically issue a COMMIT after each command, so that it may appear that there is no COMMIT required or that no transaction handling would be involved.一些 SQL 编辑器/查询 UI 工具(如 DBSquirrel)使用autocommit=true或在每个命令后自动发出COMMIT ,因此可能看起来不需要COMMIT或不涉及事务处理。

That is a false impression.那是一种错误的印象。 In fact, even SELECT s (which "just" read data) technically are always in a transaction context.事实上,即使是SELECT (它“只是”读取数据)在技术上总是在事务上下文中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM