chapter_006/src/main/java/ru/job4j/parser/DataBase.java
/**
     * Check table existence if not create table.
     */
Check table existence if not create table.
Check table existence if not create table .
public boolean checkTable() {
        boolean newTable = false;
        if (this.conn == null) {
            connect();
        }
        try {
            LOGGER.info("--------CHECK TABLE--------");
            DatabaseMetaData dbm = this.conn.getMetaData();
            this.rs = dbm.getTables(null, null, "offers", null);
            if (!rs.next()) {
                LOGGER.info("--------CREATE TABLE--------");
                this.st = conn.prepareStatement(CREATE_TABLE);
                this.st.executeUpdate();
                newTable = true;
            }
        } catch (SQLException e) {
            LOGGER.error(e.getMessage(), e);
        }
        return newTable;
    }
public boolean checkTable ( ) { boolean newTable = false ; if ( this . conn == null ) { connect ( ) ; } try { LOGGER . info ( "--------CHECK TABLE--------" ) ; DatabaseMetaData dbm = this . conn . getMetaData ( ) ; this . rs = dbm . getTables ( null , null , "offers" , null ) ; if ( ! rs . next ( ) ) { LOGGER . info ( "--------CREATE TABLE--------" ) ; this . st = conn . prepareStatement ( CREATE_TABLE ) ; this . st . executeUpdate ( ) ; newTable = true ; } } catch ( SQLException e ) { LOGGER . error ( e . getMessage ( ) , e ) ; } return newTable ; }
Check table existence if not create table.
Check table existence if not create table .