JDBC insert multiple rows

后端 未结 5 1884
别跟我提以往
别跟我提以往 2020-12-14 01:14

I am now using batch:

String query = \"INSERT INTO table (id, name, value) VALUES (?, ?, ?)\";
PreparedStatement ps = connection.prepareStatement(query);             


        
5条回答
  •  既然无缘
    2020-12-14 01:36

    First of all, with query string concatenation you not only lose the type conversion native to PreparedStatement methods, but you also get vulnerable to malicious code being executed in the database.

    Second, PreparedStatements are previously cached in the very database itself, and this already gives a very good performance improvement over plain Statements.

提交回复
热议问题