189 8069 5689

java审核学生账号代码,java审核学生账号代码错误

登录界面的java代码,分别有教师登录,管理员登录,学生登录,右边是用户名和密码,见图。

分三个包,自己建个包,导进去就ok了,数据库是access的。

创新互联公司是一家专注于网站设计制作、网站设计与策划设计,双城网站建设哪家好?创新互联公司做网站,专注于网站建设10年,网设计领域的专业建站公司;建站业务涵盖:双城等地区。双城做网站价格咨询:18980820575

package 登录;

import java.awt.EventQueue;

public class Cilent {

private JFrame frame;

private JTextField textField;

private JPasswordField passwordField;

/**

* Launch the application.

*/

public static void main(String[] args) {

EventQueue.invokeLater(new Runnable() {

public void run() {

try {

Cilent window = new Cilent();

window.frame.setVisible(true);

} catch (Exception e) {

e.printStackTrace();

}

}

});

}

/**

* Create the application.

*/

public Cilent() {

initialize();

}

/**

* Initialize the contents of the frame.

*/

private void initialize() {

frame = new JFrame();

frame.setTitle("登陆界面");

frame.setBounds(100, 100, 450, 300);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.getContentPane().setLayout(null);

frame.setResizable(false);

JLabel lblNewLabel = new JLabel("用户名");

lblNewLabel.setBounds(38, 43, 80, 34);

frame.getContentPane().add(lblNewLabel);

textField = new JTextField();

textField.setBounds(155, 42, 227, 37);

frame.getContentPane().add(textField);

textField.setColumns(10);

JLabel label = new JLabel("密 码");

label.setBounds(38, 115, 80, 34);

frame.getContentPane().add(label);

passwordField = new JPasswordField();

passwordField.setBounds(155, 115, 227, 37);

frame.getContentPane().add(passwordField);

JButton btnNewButton = new JButton("登 录");

btnNewButton.setBounds(60, 187, 115, 34);

frame.getContentPane().add(btnNewButton);

btnNewButton.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent arg0) {

// TODO Auto-generated method stub

UserCheck UC=new UserCheck(textField.getText(),String.valueOf(passwordField.getPassword()));

if(UC.getI()!=0) //有此用户

{

frame.setVisible(false);

}

else

{

textField.setText("");

passwordField.setText("");

}

}

});

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

button.setBounds(242, 187, 115, 34);

frame.getContentPane().add(button);

button.addActionListener(new ActionListener() {

@Override

public void actionPerformed(ActionEvent arg0) {

// TODO Auto-generated method stub

textField.setText("");

passwordField.setText("");

}

});

}

}

/*****************************************************************/

package 登录;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import 操作处理.UsersCL;

/**@author 20111024

* 检测登录的用户在数据库中有无,若没有,则提示没有此用户,

* 若有,则判断级别:普通用户还是管理员。

*/

public class UserCheck {

private int i=0; //用户级别:0不是用户、1是管理员、2是普通用户

UserCheck(String name ,String password)

{

String jdriver="sun.jdbc.odbc.JdbcOdbcDriver";

String connectDB="jdbc:odbc:Students";

Statement stmt=null;

ResultSet rs=null;

Connection con=null;

try {

Class.forName(jdriver);

con=DriverManager.getConnection(connectDB);

stmt=con.createStatement();

String query="select * from users where name='"+name+"' and passwd='"+password+"'";

rs=stmt.executeQuery(query);

if(rs.next())

{

//数据库中有此用户,访问成功

i=Integer.parseInt(rs.getString(3));

UsersCL UL=new UsersCL(i);

}

else

{

i=0; //没有用户是默认是0级

}

} catch (ClassNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

public int getI() {

return i;

}

}

/********************************************************************************************/

package 操作处理;

import java.awt.EventQueue;

public class UsersCL implements ActionListener{

private JFrame frame;

private JTextField textField;

private JTextField textField_1;

private JTextField textField_2;

private JTextField textField_3;

private int i=0;

private JLabel label_3;

private JTextField textField_4;

public UsersCL(int i) {

this.i=i;

frame = new JFrame();

frame.setTitle("用户处理界面");

frame.setBounds(100, 100, 450, 300);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.getContentPane().setLayout(null);

frame.setResizable(false);

frame.setVisible(true);

JLabel lblNewLabel = new JLabel("学 号");

lblNewLabel.setBounds(24, 32, 74, 29);

frame.getContentPane().add(lblNewLabel);

JLabel label = new JLabel("姓 名");

label.setBounds(24, 71, 74, 29);

frame.getContentPane().add(label);

JLabel label_1 = new JLabel("年 龄");

label_1.setBounds(24, 110, 74, 29);

frame.getContentPane().add(label_1);

label_3 = new JLabel("性 别");

label_3.setBounds(24, 149, 74, 29);

frame.getContentPane().add(label_3);

JLabel label_2 = new JLabel("状 态");

label_2.setBounds(24, 195, 74, 29);

frame.getContentPane().add(label_2);

textField = new JTextField();

textField.setBounds(101, 34, 113, 25);

frame.getContentPane().add(textField);

textField.setColumns(10);

textField_1 = new JTextField();

textField_1.setColumns(10);

textField_1.setBounds(101, 73, 113, 25);

frame.getContentPane().add(textField_1);

textField_2 = new JTextField();

textField_2.setColumns(10);

textField_2.setBounds(101, 112, 113, 25);

frame.getContentPane().add(textField_2);

textField_3 = new JTextField();

textField_3.setEditable(false);

textField_3.setColumns(10);

textField_3.setBounds(101, 199, 288, 25);

frame.getContentPane().add(textField_3);

textField_4 = new JTextField();

textField_4.setColumns(10);

textField_4.setBounds(101, 149, 113, 25);

frame.getContentPane().add(textField_4);

if(1==i)

{

JButton btnNewButton = new JButton("追 加");

btnNewButton.setBounds(276, 41, 113, 29);

frame.getContentPane().add(btnNewButton);

btnNewButton.addActionListener(this);

btnNewButton.setActionCommand("追加");

JButton button_1 = new JButton("删 除");

button_1.setBounds(276, 145, 113, 29);

frame.getContentPane().add(button_1);

button_1.addActionListener(this);

button_1.setActionCommand("删除");

}

JButton button = new JButton("查 询");

button.setBounds(276, 91, 113, 29);

frame.getContentPane().add(button);

button.addActionListener(this);

button.setActionCommand("查询");

}

@Override

public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub

String name,age,sex,query=null;

int num,age1,count=0;

num=Integer.parseInt(textField.getText());

name=textField_1.getText();

age1=Integer.parseInt(textField_2.getText());

sex=textField_4.getText();

if(e.getActionCommand().equals("追加"))

{

query="insert into students values("+num+","+"'"+name+"',"+age1+",'"+sex+"');";

count=1;

}

else if(e.getActionCommand().equals("查询"))

{

query="select * from students where XSB="+num+";";

count=2;

}

else if(e.getActionCommand().equals("删除"))

{

query="delete from students where XSB="+num+" and name="+"'"+name+"'";

count=3;

}

Statement stmt=null;

ResultSet rs=null;

Connection con=null;

String jdriver="sun.jdbc.odbc.JdbcOdbcDriver";

String connectDB="jdbc:odbc:Students";

String query1=null;

try {

Class.forName(jdriver);

con=DriverManager.getConnection(connectDB);

stmt=con.createStatement();

if(count==1)

{

query1="select * from students where XSB="+num+";";

rs=stmt.executeQuery(query1);

if(rs.next())

textField_3.setText("已经由此记录,不能追加!");

else

{

stmt.executeUpdate(query);

textField_3.setText("已经追加完成!");

}

}

else if(2==count)

{

stmt.executeQuery(query);

rs=stmt.executeQuery(query);

if(rs.next())

{

textField_3.setText("已查找到此记录!");

}

else

{

textField_3.setText("没有此记录,可以追加!");

}

}

else if(3==count)

{

query1="select * from students where XSB="+num+" and name="+"'"+name+"'";

rs=stmt.executeQuery(query1);

if(rs.next())

{

stmt.executeUpdate(query);

textField_3.setText("已删除此记录!");

}

else

textField_3.setText("无此记录!");

}

} catch (ClassNotFoundException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

} catch (SQLException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

finally{

//关闭资源

if(stmt!=null){

try {

stmt.close();

} catch (Exception e2) {

// TODO: handle exception

}

stmt=null;

}

if(con!=null){

try {

con.close();

} catch (Exception e2) {

// TODO: handle exception

}

con=null;

}

}

}

}

求大神用java初级语言帮忙写《学生信息管理系统》说明书代码

你这太搞笑了,淘宝上做项目的多了去了,但是都是要钱的~100财富值谁给你写啊

简单的JAVA学生管理系统代码···

lListStudent students = new ArrayListStudent();

BufferedReader br = new BufferedReader(new FileReader("D:\student.txt"));

String tmpStr = br.readLine();

while(tmpStr != null){

int firstIndex = tmpStr.indexOf(" ");

int secondIndex = tmpStr.indexOf(" ",firstIndex + 1);

int thirdIndex = tmpStr.indexOf(" ", secondIndex + 1);

int forthIndex = tmpStr.indexOf(" ", thirdIndex + 1);

Integer stuId = Integer.parseInt(tmpStr.substring(0,firstIndex));

String stuName = tmpStr.substring(firstIndex + 1,secondIndex);

Integer stuYW = Integer.parseInt(tmpStr.substring(secondIndex + 1,thirdIndex));

Integer stuSX = Integer.parseInt(tmpStr.substring(thirdIndex + 1,forthIndex));

Integer stuYY = Integer.parseInt(tmpStr.substring(forthIndex + 1));

Student student = new Student();

student.setStuId(stuId);

student.setStuName(stuName);

student.setStuYW(stuYW);

student.setStuSX(stuSX);

student.setStuYY(stuYY);

students.add(student);

tmpStr.readLine();

}

//创建一个学生实体类 封装stuId stuName stuYW stuSx stuYY 这5个属性。。。

//已经帮你把数据拆分出来 并以Student 对象的形式放入集合中了 接下来 给分吧 哇咔咔

用java编写一个文件审核程序(要代码)

假定开始没有这个文件,在插入数据时建立文件。

FILE *fp;

fopen(激法馆盒弋谷龟贪骇楷"c:a.txt","wt+");这个是打开以写或读的方式打开文件。打开后就可以写入了,用for循环,例如你有4组数据,

for(int i;i=4;i++)

{

fprintf(fp,"%s%s%s%s",a,b,c,d);

}

fprintf();就实现了把数据写入文件的功能。跟printf();差不多,只是一个是往文件里写,一个是往屏幕上写。

上面就实现了插入操作。

如果你想删除一个数据,就先在数组中删除,然后重新进行上述写入文件操作。 要是读取数据的话就在打开文件时:fp = fopen("c:a.txt",r+);

要是还不明白的话就看下书,这两个函数就可以满足你的需要。

求java学生管理系统源代码 急!!!

完成了,希望能帮到你

刚开始会叫你输入编号选择功能

import java.io.*;

public class student {

public static void main(String args[]) throws IOException{

int[] stud = {77,99,55,46,82,75,65,31,74,85};

System.out.println("请选择功能:");//输入编号选择功能

System.out.println("1、输入学号,查询该学生成绩:");

System.out.println("2、输入成绩,查询学生学号:");

System.out.println("3、输入学号,删除该学生成绩");

System.out.println("请选择编号:");

BufferedReader td = new BufferedReader(new InputStreamReader(System.in));

String temp = td.readLine();

int choice = Integer.valueOf(temp);

if(choice == 1){//一为查询学生成绩

System.out.println("请输入学号:");

BufferedReader sd = new BufferedReader(new InputStreamReader(System.in));

String temp_sd = sd.readLine();

int No = Integer.valueOf(temp_sd);

System.out.print("学号为 "+No+" 的学生成绩为: " + stud[No-1] +"分");

}

if(choice == 2){//二为查询学生编号

System.out.println("请输入成绩:");

BufferedReader sd = new BufferedReader(new InputStreamReader(System.in));

String chengji = sd.readLine();

int temp_cj = Integer.valueOf(chengji);

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

if(temp_cj == stud[i]){

System.out.print("成绩为 "+ temp_cj+ "的学生的学号为: "+(i+1));

}

}

}

if(choice == 3){//三为删除操作

System.out.println("请输入学号:");

BufferedReader sd = new BufferedReader(new InputStreamReader(System.in));

String temp_sd = sd.readLine();

int No = Integer.valueOf(temp_sd);

stud[No-1]=0;//直接赋值为0,不删除学生

System.out.print("学号为 "+No+" 的学生成绩为: " + stud[No-1] +"分");

}

}

}

JAVA学生管理系统连接数据库验证系统登入代码怎么写?

可以依靠Baidu Hi告知我你的任务

有机会可处理你遇到的任务

针对此题目

我们可以提供一套适合于学生水平的源代码

如果你有具体的要求也可告知我

ES:\\3F95DDF52318580DE85E4A3C08417024

交易提醒:预付定金是诈骗

交易提醒:百度名中包含联系方式勿轻信


网站标题:java审核学生账号代码,java审核学生账号代码错误
URL分享:http://cdxtjz.cn/article/hoddpj.html

其他资讯