Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.Statement;
- import java.util.ArrayList;
- import java.util.Random;
- public class new_test {
- public static void main(String[] args) {
- ArrayList<String>objectsToStore = new ArrayList<>();
- Random rad = new Random();
- for (int j=1; j<=1; j++ )
- {
- objectsToStore.add("usename"+rad.nextInt()+"@gmail.com");
- }
- try {
- Class.forName("com.mysql.jdbc.Driver") ;
- Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?useSSL=false", "root", "");
- connection.setAutoCommit(false);
- Statement statement = connection.createStatement();
- for (String objectsToStore : objectsToStore ) {
- statement.executeUpdate("INSERT INTO USER_DATA (email) VALUES ('" +objectsToStore +"')");
- }
- connection.commit();
- statement.close();
- connection.close();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement