Inserting the records one by one will take a lot of time as 100000 execute and commit calls will be required on the PreparedStatment instances.
To avoid the time overhead, we can use the concept of the batch which will insert the 1000 records with one call of executeBatch and commit methods.
1. Create DB connection.
2. Create a query for the prepared statement.
3. Set auto commit false.
4. Prepare statement and add it to batch.
5. If the batch size is multiple of 1000 then commit the database.
6. Repeat step 4 and 5 till the complete data is loaded.
7. Close connection.
Same has been implemented below given method: