Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A detailed explanation of the usage of Oracle addBatch ()

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

A detailed explanation of the usage of Oracle addBatch ()

Use of PreparedStatement.addbatch ()

The difference between Statement and PreparedStatement is not much nonsense, just talk about the use of PreparedStatement's most important addbatch () structure.

1. Establish a link

Connection connection = getConnection ()

two。 Do not automatically Commit

Connection.setAutoCommit (false)

3. Pre-compile SQL statements, only compile once, oh, high efficiency

PreparedStatement statement = connection.prepareStatement ("INSERT INTO TABLEX VALUES"); / / record 1 statement.setInt (1,1); statement.setString (2, "Cujo"); statement.addBatch (); / record 2 statement.setInt (1,2); statement.setString (2, "Fred"); statement.addBatch (); / / record 3 statement.setInt (1,3); statement.setString (2, "Mark"); statement.addBatch () / / execute the above 3 statements in batch. Int [] counts = statement.executeBatch (); / / Commit it into (DB)

The above is the use of Oracle addBatch (), if you have any questions, please leave a message or go to the community to exchange and discuss, thank you for reading, hope to help you, thank you for your support!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report