JDBC Batch Insert OutOfMemoryError
问题 I have written a method insert() in which I am trying to use JDBC Batch for inserting half a million records into a MySQL database: public void insert(int nameListId, String[] names) { String sql = "INSERT INTO name_list_subscribers (name_list_id, name, date_added)"+ " VALUES (?, ?, NOW())"; Connection conn = null; PreparedStatement ps = null; try{ conn = getConnection(); ps = conn.prepareStatement(sql); for(String s : names ){ ps.setInt(1, nameListId); ps.setString(2, s); ps.addBatch(); } ps