Академический Документы
Профессиональный Документы
Культура Документы
*;
import java.util.Scanner;
import java.util.Random;
int index = 0;
pswd[index] = ALPHA_CAPS.charAt(rnd.nextInt(ALPHA_CAPS.length()));
pswd[index] = NUM.charAt(rnd.nextInt(NUM.length()));
pswd[index] = SPL_CHARS.charAt(rnd.nextInt(SPL_CHARS.length()));
if(pswd[i] == 0) {
pswd[i] = ALPHA.charAt(rnd.nextInt(ALPHA.length()));
return pswd;
return index;
Class.forName(JDBC_DRIVER);
System.out.println("Connecting to a selected database...");
conn = DriverManager.getConnection(DB_URL, USER, PASS);
System.out.println("Connected database successfully...");
do
{
System.out.print("\n user unique. \n2.forgot or reset
password\n3.acknowledgement. \n4.EXIT\nEnter your choice:");
opt=s.nextInt();
switch(opt)
{
case 1:
System.out.print("Enter your unique id:\t");
v1=s.nextInt(); s.nextLine();
System.out.print("Enter your FIRST NAME:\t");
v2=s.nextLine();
System.out.print("Enter your LAST NAME:\t");
v3=s.nextLine();
sql = "INSERT INTO customers (acc_num,f_name,l_name,address,open_dep)
VALUES(?,?,?,?,?)" ;
stmnt = conn.prepareStatement(sql);
stmnt.setInt(1, v1);
stmnt.setString(2, v2);
stmnt.setString(3, v3);
stmnt.setString(4, v4);
stmnt.setInt(5, v5);
stmnt.executeUpdate();
}}while(opt<=5);
}catch(SQLException se){
se.printStackTrace();
}catch(Exception e){
//Handle errors for Class.forName
e.printStackTrace();
}finally{
//finally block used to close resources
try{
if(stmnt!=null)
stmnt.close();
}catch(SQLException se){
}// do nothing
try{
if(conn!=null)
conn.close();
}catch(SQLException se){
se.printStackTrace();
}//end finally try
}//end try
System.out.println("\nHave a nice day ahead!");
}
}