public void addCalendars(List<EventCalendar> calendars) {
        Connection connection = null;
        PreparedStatement statement = null;
        PreparedStatement selectStatement = null;
        
        try {
            // Register JDBC driver
            Class.forName("com.mysql.jdbc.Driver");

            // Open a connection
            System.out.println("Connecting to database...");
            connection = DriverManager.getConnection(DB_URL,USER,PASS);

            System.out.println("Creating statement...");
            

            
            String sqlInsert = "INSERT INTO calendar VALUES(?)";
            statement = connection.prepareStatement(sqlInsert);

            // Inserts all the possible calendars that an event can have into the calendar table
            for (EventCalendar calendar : calendars) { 
                
                //check if the calendar already exists in the database
                String sqlSelect = "SELECT name FROM calendar WHERE name = \"" + calendar.getNameOfCalendar() + "\"";
                selectStatement = connection.prepareStatement(sqlSelect);
                ResultSet executeQuery = selectStatement.executeQuery();
                
                if(!executeQuery.next()){
                    System.out.println("Inserting calendar: " + calendar.getNameOfCalendar());

                    statement.setString(1, calendar.getNameOfCalendar());
                    statement.executeUpdate();
                }
            }

            statement.close();
            connection.close();
        } catch(SQLException se) {
           se.printStackTrace();
        } catch(Exception e) {
           e.printStackTrace();
        } finally {
            try{
               if (statement != null) {
                  statement.close();
               }
            } catch(SQLException se2) {
            }
            try {
               if (connection != null) {
                  connection.close();
               }
            } catch (SQLException se) {
               se.printStackTrace();
            }
        }    
    }