chapter_002/src/main/java/ru/job4j/start/Tracker.java
/**
     * Check table existence.
     * If the table is not created, create a table.
     */
Check table existence.
If the table is not created, create a table.
Check table existence . If the table is not created create a table .
private void checkTable() {
        if (!createTable) {
            try {
                DatabaseMetaData dbm = conn.getMetaData();
                ResultSet rs = dbm.getTables(null, null, "users", null);
                if (!rs.next()) {
                    PreparedStatement st = conn.prepareStatement(CREATE_TABLE);
                    st.executeUpdate();
                    createTable = true;
                }
            } catch (SQLException e) {
                LOGGER.error(e.getMessage(), e);
            }
        }
    }
private void checkTable ( ) { if ( ! createTable ) { try { DatabaseMetaData dbm = conn . getMetaData ( ) ; ResultSet rs = dbm . getTables ( null , null , "users" , null ) ; if ( ! rs . next ( ) ) { PreparedStatement st = conn . prepareStatement ( CREATE_TABLE ) ; st . executeUpdate ( ) ; createTable = true ; } } catch ( SQLException e ) { LOGGER . error ( e . getMessage ( ) , e ) ; } } }
Check table existence.
Check table existence .