JDBC and Oracle conn.commit and conn.setAutocommit not working properly

前端 未结 4 1416
-上瘾入骨i
-上瘾入骨i 2021-01-12 15:52

I have made a DBManager class as shown below

public class DBManager {


      public static String DRIVER = \"oracle.jdbc.driver.OracleDriver\";
      public         


        
4条回答
  •  余生分开走
    2021-01-12 16:23

    TRUNCATE TABLE basically doesn't allow commit/rollback in the normal way. As per this documentation:

    Because a Truncate is DDL it issues a COMMIT before it acts and another COMMIT afterward so no rollback of the transaction is possible.

    If you want to do this as part of a transaction, use DML instead - e.g. a normal DELETE FROM ... statement.

提交回复
热议问题