「注册功能java」注册功能安全工程师

博主:adminadmin 2023-01-11 16:09:09 517

本篇文章给大家谈谈注册功能java,以及注册功能安全工程师对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

java实现 做一个简单的用户注册系统

package test1;

/**

 * 用户类

 */

public class User {

private String name;

private int age;

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

@Override

public String toString() {

return "User [name=" + name + ", age=" + age + "]";

}

}

package test1;

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

/**

* 主方法类

*/

public class Test1 {

// 创建键盘输入对象

static Scanner input = new Scanner(System.in);

// 存储用户

static ListUser userList = new ArrayList();

public static void main(String[] args) {

try {

// 初始化数据

User e1 = new User();

e1.setName("张三");

e1.setAge(18);

User e2 = new User();

e2.setName("李四");

e2.setAge(21);

userList.add(e1);

userList.add(e2);

while (true) {

System.out.println("=========菜单=========");

System.out.println("1.增加新用户;2.修改用户;3.删除用户;4.查找用户;5.退出)");

System.out.println("请键入对应的数字(1-5)进入相应的功能");

int handle = input.nextInt();

caseMenu(handle);

}

} catch (Exception e) {

throw new RuntimeException("请输入正确的内容!");

}

}

/*

* 选择菜单

*/

private static void caseMenu(int handle) {

try {

s: switch (handle) {

case 1:

// 新增用户

User user = new User();

System.err.print("请输入用户名:");

String name = input.next();

// 判断用户名是否已存在

f: for (User u : userList) {

if (u.getName().equals(name)) {

System.err.println("用户名已存在, 新增失败");

// 直接跳出switch

break s;

}

}

System.err.print("请输入年龄:");

int age = input.nextInt();

// 将新增用户插入List集合

user.setName(name);

user.setAge(age);

userList.add(user);

System.out.println("新增用户成功!");

// 查询所有用户

showAllUsers();

break;

case 2:

// 修改用户

System.err.print("请输入需要修改年龄的用户名:");

String uName = input.next();

// 判断用户名是否已存在

f: for (User u : userList) {

if (u.getName().equals(uName)) {

System.err.print(uName + "年龄修改为: ");

int uAge = input.nextInt();

u.setAge(uAge);

System.err.println("修改成功!");

showAllUsers();

// 直接跳出switch

break s;

}

}

System.err.println("用户名为:" + uName + "的用户不存在, 修改失败!");

break;

case 3:

// 删除用户

System.err.print("请输入要删除的用户名:");

String dName = input.next();

// 判断用户名是否已存在

f: for (User u : userList) {

if (u.getName().equals(dName)) {

System.err.print("确定要删除\"" + dName + "\"用户吗?(y/n)");

String isYes = input.next();

if ("y".equals(isYes)) {

userList.remove(u);

System.err.println("删除成功!");

} else {

System.err.println("删除操作取消..");

}

showAllUsers();

// 直接跳出switch

break s;

}

}

System.err.println("用户名为:" + dName + "的用户不存在, 删除失败!");

break;

case 4:

// 查找用户

System.err.print("请输入要查找的用户名:");

String sName = input.next();

// 判断用户名是否已存在

f: for (User u : userList) {

if (u.getName().equals(sName)) {

boolean flag = userList.contains(u);

System.err.println("用户名: " + u.getName() + "\t年龄: " + u.getAge());

// 直接跳出switch

break s;

}

}

System.err.println("用户名为:" + sName + "的用户不存在, 查询失败!");

break;

case 5:

// 系统退出

// 关闭键盘输入流

input.close();

System.exit(0);

break;

default:

break;

}

} catch (Exception e) {

throw new RuntimeException("请输入正确的内容!");

}

}

/*

* 查询所有用户

*/

private static void showAllUsers() {

for (User u : userList) {

System.out.println("姓名: " + u.getName() + "\t年龄: " + u.getAge());

}

}

}

java 使用socket完成一个控制台的登录/注册功能

你可以在注册成功的时候,把资料保存到数据库,然后执行sql的使用会有影响行数的嘛。当影响行数为1的时候就把该对象放在session中

java语言实现用户注册和登录

//这个是我写的,里面有连接数据库的部分。你可以拿去参考一下

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

import java.sql.*;

class LoginFrm extends JFrame implements ActionListener// throws Exception

{

JLabel lbl1 = new JLabel("用户名:");

JLabel lbl2 = new JLabel("密码:");

JTextField txt = new JTextField(5);

JPasswordField pf = new JPasswordField();

JButton btn1 = new JButton("确定");

JButton btn2 = new JButton("取消");

public LoginFrm() {

this.setTitle("登陆");

JPanel jp = (JPanel) this.getContentPane();

jp.setLayout(new GridLayout(3, 2, 5, 5));

jp.add(lbl1);

jp.add(txt);

jp.add(lbl2);

jp.add(pf);

jp.add(btn1);

jp.add(btn2);

btn1.addActionListener(this);

btn2.addActionListener(this);

}

public void actionPerformed(ActionEvent ae) {

if (ae.getSource() == btn1) {

try {

Class.forName("com.mysql.jdbc.Driver");// mysql数据库

Connection con = DriverManager.getConnection(

"jdbc:mysql://localhost/Car_zl", "root", "1");// 数据库名为Car_zl,密码为1

System.out.println("com : "+ con);

Statement cmd = con.createStatement();

String sql = "select * from user where User_ID='"

+ txt.getText() + "' and User_ps='"

+ pf.getText() + "'" ;

ResultSet rs = cmd

.executeQuery(sql);// 表名为user,user_ID和User_ps是存放用户名和密码的字段名

if (rs.next()) {

JOptionPane.showMessageDialog(null, "登陆成功!");

} else

JOptionPane.showMessageDialog(null, "用户名或密码错误!");

} catch (Exception ex) {

}

if (ae.getSource() == btn2) {

System.out.println("1111111111111");

//txt.setText("");

//pf.setText("");

System.exit(0);

}

}

}

public static void main(String arg[]) {

JFrame.setDefaultLookAndFeelDecorated(true);

LoginFrm frm = new LoginFrm();

frm.setSize(400, 200);

frm.setVisible(true);

}

}

java使用面向对象写一个登录注册查询的功能

import java.util.Scanner;/**

* 采用面向对象的方式 写一个登录系统

* @author Administrator

*

*///用户信息class UserInfo{ public static String[] user = new String[10]; public static String[] passwd = new String[10];

public UserInfo() { this.user[0] = "test"; this.passwd[0] ="123456";

}

}//找回密码class ZhaoHui extends UserInfo{ public static void zhaohui() {

Scanner s = new Scanner(System.in);

System.out.println("请输入你要找回的用户名:");

String zname = s.nextLine(); for(int i=0;i2;i++) { if(user[i].equals(zname)) {

Scanner ss = new Scanner(System.in);

System.out.println("恭喜你!成功找回密码,请输入:"+"'张哥最帅'"+" 查看密码");

String zgzs = ss.nextLine();

if("张哥最帅".equals(zgzs)) {

System.out.println(passwd[i]);

}else {

System.out.println("请输正确!");

}

}else if(user[i]!=zname){

System.out.println("用户名不存在!"); return;

}

break;

}

}

}//修改密码 class XiuGai extends UserInfo{ public static void xiugai() {

Scanner s =new Scanner(System.in);

System.out.println("请输入您要修改的密码:");

String xpasswd = s.nextLine(); for(int i=0;i2;i++) {

passwd[i] = xpasswd; if(xpasswd.equals(passwd[i])) {

System.out.println("恭喜你,修改成功!"); break;

}else {

System.out.println("修改密码失败"); break;

}

}

}

}//查询用户class ChaXun extends UserInfo{

public static void select() { for(int i=0;i2;i++) {

System.out.println("当前用户:"+user[i] +"\n"+ "当前密码:"+passwd[i] );

i++; break;

}

}

}//注册class ZhuCe extends UserInfo{

public static void regist() {

Scanner ss = new Scanner(System.in);

System.out.println("请输入用户名:");

String suser = ss.nextLine();

System.out.println("请输入密码:");

String spasswd = ss.nextLine();

for(int i=0;iuser.length;i++) {

user[i] = suser;

passwd[i] = spasswd;

System.out.println("注册成功!"); break;

}

}

}//登录class Loginc extends UserInfo{

public static void login() { int flag = 1;

Scanner scanner = new Scanner(System.in);

System.out.println("请输入用户名:");

String users = scanner.nextLine();

System.out.println("请输入密码:");

String passwds = scanner.nextLine();

for(int i=0;iUserInfo.user.length;i++) { if(user[i].equals(users) passwd[i].equals(passwds)) {

System.out.println("登陆成功!"); break;

}

System.out.println("登陆失败!"); break;

}

}

}//主界面class ZhuJieMian{ public static void Start() {

Loginc Loginc = new Loginc();

ZhuCe ZhuCe = new ZhuCe();

ChaXun ChaXun = new ChaXun();

XiuGai XiuGai = new XiuGai();

ZhaoHui ZhaoHui = new ZhaoHui();

Scanner s = new Scanner(System.in); while(true) {

System.out.println("|"+ "\t"+ "\t"+ "\t"+ "\t"+ "\t"+ "\t"+ "\t"+"\t"+"|");

System.out.println("|"+"\t" + "测试用户名:test 测试密码:123456" + "\t"+ "\t"+ "\t"+ "\t"+"|");

System.out.println("|" + "\t"+ "请输入[1-5]进行操作 1.登录|2.注册|3.查询当前用户|4.修改密码|5.找回密码 " + "\t"+"|");

System.out.print("请输入:"); int temp = s.nextInt();

switch(temp) { case 1:Loginc.login(); break; case 2:ZhuCe.regist();; break; case 3:ChaXun.select();; break; case 4:XiuGai.xiugai();; break; case 5:ZhaoHui.zhaohui();; break; default:System.out.println("错误!请重写输入正确的数字进行操作!");

}

}

}

}public class LoginTest { public static void main(String[] args) {

ZhuJieMian zjm = new ZhuJieMian();

zjm.Start();

}

}

性能测试中如何使用java批量注册登录账户

性能测试中示例代码使用java批量注册登录账户。

性能测试过程中所需的测试数据,以登录为例,为了更真实的模 批量读取注册。

Java登录注册功能实现代码解析,文中通示例代码,每个用户信息都是唯一的,所以可以借助Set的特性来操作用户信息的存放。

注册功能java的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于注册功能安全工程师、注册功能java的信息别忘了在本站进行查找喔。