chapter_006/src/main/java/ru/job4j/store/StoreSQL.java
/**
     * Create recods in the db.
     *
     * @param n - quantity of generated records.
     */
Create recods in the db.
@param n - quantity of generated records.
Create recods in the db . @param n - quantity of generated records .
public void generate(int n) {
        this.st = null;
        this.rs = null;
        checkTable();
        for (int x = 1; x <= n; x++) {
            try {
                this.conn.setAutoCommit(false);
                this.st = conn.prepareStatement(ADD_ELEMENT);
                this.st.setInt(1, x);
                this.st.executeUpdate();
                this.conn.setAutoCommit(true);
            } catch (Exception e) {
                try {
                    this.conn.rollback();
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
                LOGGER.error(e.getMessage(), e);
            }
        }
    }
public void generate ( int n ) { this . st = null ; this . rs = null ; checkTable ( ) ; for ( int x = 1 ; x <= n ; x ++ ) { try { this . conn . setAutoCommit ( false ) ; this . st = conn . prepareStatement ( ADD_ELEMENT ) ; this . st . setInt ( 1 , x ) ; this . st . executeUpdate ( ) ; this . conn . setAutoCommit ( true ) ; } catch ( Exception e ) { try { this . conn . rollback ( ) ; } catch ( SQLException e1 ) { e1 . printStackTrace ( ) ; } LOGGER . error ( e . getMessage ( ) , e ) ; } } }
Create recods in the db.
Create recods in the db .