Java: Insert multiple rows into MySQL with PreparedStatement

后端 未结 6 1259
后悔当初
后悔当初 2020-11-22 16:28

I want to insert multiple rows into a MySQL table at once using Java. The number of rows is dynamic. In the past I was doing...

for (String element : array)          


        
6条回答
  •  情深已故
    2020-11-22 16:45

    we can be submit multiple updates together in JDBC to submit batch updates.

    we can use Statement, PreparedStatement, and CallableStatement objects for bacth update with disable autocommit

    addBatch() and executeBatch() functions are available with all statement objects to have BatchUpdate

    here addBatch() method adds a set of statements or parameters to the current batch.

提交回复
热议问题