/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2015 Aleksandar Cvetković
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package htsquirrel;

import static htsquirrel.FileManagement.*;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author Aleksandar Cvetković <arcvetkovic@gmail.com>
 */
public class DatabaseManagement {
    
    // create database connection
    public static Connection createDatabaseConnection()
            throws IOException,ClassNotFoundException, SQLException {
        deleteDatabaseDir();
        String dbUrl = "jdbc:h2:" + getDatabasePathShort();
        Class.forName("org.h2.Driver");
        Connection connection = DriverManager.getConnection(dbUrl);
        return connection;
    }
    
    // check if table exists
    public static boolean tableExists(Connection connection, String tableName)
            throws SQLException {
        boolean tableExists = false;
        DatabaseMetaData dbMetaData = connection.getMetaData();
        ResultSet resultSet = dbMetaData.getTables(null, null, null, null);
        while (resultSet.next()) {
            if (tableName.equals(resultSet.getString("TABLE_NAME"))) {
                tableExists = true;
            }
        }
        return tableExists;
    }

}

@@ -1387,16 +1387,43 @@
 ception;
+%0Aimport java.sql.Statement;
 %0A%0A/**%0A *
@@ -2435,12 +2435,1357 @@
 s;%0A    %7D
+%0A    %0A    // create teams table%0A    public static void createTeamsTable(Connection connection)%0A            throws SQLException %7B%0A        String sqlCode = %22CREATE TABLE TEAMS (%22 +%0A                %22USER_ID INT,%22 +%0A                %22LOGIN_NAME VARCHAR(255),%22 +%0A                %22SUPPORTER_TIER VARCHAR(255),%22 +%0A                %22TEAM_ID INT,%22 +%0A                %22TEAM_NAME VARCHAR(255),%22 +%0A                %22SHORT_TEAM_NAME VARCHAR(255),%22 +%0A                %22FOUNDED_DATE TIMESTAMP,%22 +%0A                %22PRIMARY_CLUB BOOLEAN,%22 +%0A                %22ARENA_ID INT,%22 +%0A                %22ARENA_NAME VARCHAR(255),%22 +%0A                %22LEAGUE_ID INT,%22 +%0A                %22LEAGUE_NAME VARCHAR(255),%22 +%0A                %22REGION_ID INT,%22 +%0A                %22REGION_NAME VARCHAR(255),%22 +%0A                %22COACH_ID INT,%22 +%0A                %22LEAGUE_LEVEL_UNIT_ID INT,%22 +%0A                %22LEAGUE_LEVEL_UNIT_NAME VARCHAR(255),%22 +%0A                %22LEAGUE_LEVEL INT,%22 +%0A                %22FANCLUB_ID INT,%22 +%0A                %22FANCLUB_NAME VARCHAR(255),%22 +%0A                %22FANCLUB_SIZE INT,%22 +%0A                %22LOGO_URI VARCHAR(255),%22 +%0A                %22DRESS_URI VARCHAR(255),%22 +%0A                %22DRESS_ALTERNATE_URI VARCHAR(255)%22 +%0A                %22)%22;%0A        Statement statement = connection.createStatement();%0A        statement.execute(sqlCode);%0A        statement.close();%0A    %7D
 %0A%0A%7D%0A

Add createTeamsTable