Get the App
SLTechnology News&Howtos  ›  Database  › 

How to randomly generate eight-digit discount codes and save them to Mysql database

Shulou Source: shulou.com Published: 2022-05-31 19:47:22 09月27日 Update

This article is about how to randomly generate eight-digit discount codes and save them to the Mysql database. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

At present, many businesses do activities through the discount code, and now we simply achieve the eight-digit discount code and save it in the database.

1. The randomly generated discount code is as follows:

Import java.util.Random;/*** function: randomly generate discount codes * @ author iamwiam**/public class Activatedcode {public int ACTIVATEDCODENUM = 200; / / number of generated discount codes Random random = new Random (); String candicatedCode = "abcedefghijklmnopqrstuvwxyz"; / / discount codes contain lowercase letters candicatedCode+=candicatedCode.toUpperCase () / / the discount code contains the uppercase letters candicatedCode+= "1234567890"; / / the discount code contains the Arabic numerals for (int item0; I < ACTIVATEDCODENUM;i++) {String res = ""; for (int job0witj)

Tags: Offers generation data database content functions parameters letters more articles good practical code location merchants uppercase uppercase lowercase quantity articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Linux MariaDB Shulou Tech Info vpn