java 批量插入資料 到資料庫,java資料庫

來源:互聯網
上載者:User

java 批量插入資料 到資料庫,java資料庫

//大資料插入方式String sql = "insert into T_DR_RF(CUSTOMER_CODE,RFID_TAG) values(?,?)";Connection connection =db.getConnection();connection.setAutoCommit(false);PreparedStatement ps = connection.prepareStatement(sql);for (Map<String, Object> map : coll) {String p1 = Tools.toString(map.get("customerCode"));String p2 = Tools.toString(map.get("rfidTag"));ps.setString(1, p1);ps.setString(2, p2);ps.addBatch();}ps.executeBatch();connection.commit();System.out.println("匯入完成");

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.