有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (3) 个答案

  1. # 1 楼答案

    是的,很有效。实际上,自动提交在默认情况下处于启用状态。这个chapter会给你一个想法,但为了节省你一些时间:

    By default, JDBC's auto-commit feature is on, which means that each SQL statement is committed as it is executed. If more than one SQL statement is executed by your program, then a small performance increase can be achieved by turning off auto-commit.

    也请阅读CallableStatement部分:

    As you may recall, CallableStatement objects are used to execute database stored procedures. I've saved CallableStatement objects until last, because they are the slowest performers of all the JDBC SQL execution interfaces. This may sound counterintuitive, because it's commonly believed that calling stored procedures is faster than using SQL, but that's simply not true. Given a simple SQL statement, and a stored procedure call that accomplishes the same task, the simple SQL statement will always execute faster. Why? Because with the stored procedure, you not only have the time needed to execute the SQL statement but also the time needed to deal with the overhead of the procedure call itself.

    我认为这将有助于您对应用程序的性能做出决定

  2. # 2 楼答案

    一句话:是的。只需确保不在存储过程中嵌入事务逻辑。这一切都由JDBC驱动程序或事务管理器决定

    没有什么比亲自尝试并亲眼目睹更棒的了。我觉得这比在这里提问更好

  3. # 3 楼答案

    这行不通,连接。setAutoCommit(true),在这个连接中是一个Java对象。不能在存储过程中使用相同的方法

    我们有一个名为autocommit的sql系统变量,如果我们在编写存储过程时将其设置为on,那么无论您试图执行什么,您的过程都会自动提交结果