This article is a mirror article of machine translation, please click here to jump to the original article.

View: 13586|Reply: 2

[JavaSE] Student information management system written by JAVA

[Copy link]
Posted on 11/20/2014 8:43:50 PM | |Browse in order |
This post was last edited by Delver_Si on 2014-11-20 21:21

[mw_shl_code=sql,true]use master
go
if exists(select * from sys.databases where name = 'school')
        drop database school
go
create database school
go
use school
go
create table student
(
        stu_id varchar(10) primary key ,-- number
        stu_name varchar(20) not null,-- name
        stu_addr Varchar (100) ,-- address
        stu_spec varchar (50) ,-- professional
        stu_dorm Varchar (50) — Dormitory
)
go
insert into student values('100001','Zhang San','Wuhan Xu Dong','Information Engineering','101')
insert into student values('100002','Li Si','Wuhan Xu Dong','Information Engineering','102')

select * from student

--delete from student where stu_id = '100001'

--update student set stu_name = 'Li Si', stu_addr = 'Zhang San', stu_spec= 'Software Testing', stu_dorm = '1001' where stu_id = '100001'[/mw_shl_code]

[mw_shl_code=java,true]package online.school.test;

import java.util.ArrayList;
import java.util.List; import online.school.domain.Student;
import online.school.service.StudentService;

public class StudentTest {

        public static void main(String[] args) {
                new StudentTest().getAllStudent();
        }
        public int addStudent() {
                Student student = new Student("3","Wang Wu","Xiaogan","Software Testing","103");
                return new StudentService().addStudent(student);
        }

        public int delStudent() {
                String stuId="3";
                return new StudentService().delStudent(stuId);
        }

        public void findStudent() {
                String stuId="3";
                Student student =new StudentService().findStudent(stuId);
                System.out.println(student.toString());
        }

        public List<Student> getAllStudent() {
                ArrayList al =  (ArrayList) new StudentService().getAllStudent();
                for(int i =0; i<al.size(); i++){
                        Object[] obj =(Object[]) al.get(i);
                        for(int j=0; j<5; j++){
                                System.out.print(obj[j] + " ");
                        }
                        System.out.println();
                }
                return al;
        }

        public int  updateStudent() {

                Student student = new Student("3","Wang Wu","Yingcheng","Civil Engineering","103");
                new StudentService().updateStudent(student);
                return 0;
               
        }
}
[/mw_shl_code]

[mw_shl_code=java,true]package online.school.domain;

public class Student {
        
        private String stu_id; number
        private String stu_name; Name
        private String stu_addr; - Address
        private String stu_spec; Professional
        private String stu_dorm; Dormitory
        public String getStu_id() {
                return stu_id;
        }
        public void setStu_id(String stuId) {
                stu_id = stuId;
        }
        public String getStu_name() {
                return stu_name;
        }
        public void setStu_name(String stuName) {
                stu_name = stuName;
        }
        public String getStu_addr() {
                return stu_addr;
        }
        public void setStu_addr(String stuAddr) {
                stu_addr = stuAddr;
        }
        public String getStu_spec() {
                return stu_spec;
        }
        public void setStu_spec(String stuSpec) {
                stu_spec = stuSpec;
        }
        public String getStu_dorm() {
                return stu_dorm;
        }
        public void setStu_dorm(String stuDorm) {
                stu_dorm = stuDorm;
        }
        
        
        
        public Student() {
                super();
        }
        public Student(String stuId, String stuName, String stuAddr,
                        String stuSpec, String stuDorm) {
                super();
                stu_id = stuId;
                stu_name = stuName;
                stu_addr = stuAddr;
                stu_spec = stuSpec;
                stu_dorm = stuDorm;
        }
        @Override
        public String toString() {
                return "Student [stu_addr=" + stu_addr + ", stu_dorm=" + stu_dorm
                                + ", stu_id=" + stu_id + ", stu_name=" + stu_name
                                + ", stu_spec=" + stu_spec + "]";
        }
        
        
        

}
[/mw_shl_code]
[mw_shl_code=java,true]package online.school.service;

import java.util.List;

import online.school.dao.StudentDao;
import online.school.domain.Student;
import online.school.utils.SqlHelp;

public class StudentService implements IStudentService{

        @Override
        public int addStudent(Student student) {
               
                String sql = "insert into student values(?,?,?,?,?)";
                return new StudentDao().addStudent(sql,student.getStu_id(),student.getStu_name(),student.getStu_addr(),student.getStu_spec(),student.getStu_dorm());
        }

        @Override
        public int delStudent(String stuId) {
                String sql = "delete from student where stu_id = ?";
                return new StudentDao().delStudent(sql, stuId);
        }

        @Override
        public Student findStudent(String stuId) {
                String sql = "select * from student where stu_id = ?";
                return new StudentDao().findStudent(sql, stuId);
        }

        @Override
        public List<Student> getAllStudent() {
                String sql = "select * from student";
                return new StudentDao().getAllStudent(sql);
        }

        @Override
        public int updateStudent(Student student) {
                String sql = "update  student set  stu_name = ?,stu_addr = ?, stu_spec= ?,stu_dorm = ? where stu_id = ?";
                return new StudentDao().updateStudent(sql, student.getStu_name(),student.getStu_addr(),student.getStu_spec(),student.getStu_dorm(),student.getStu_id());
               
        }

        

        
}
[/mw_shl_code] [mw_shl_code=java,true]package online.school.dao;

import java.util.ArrayList;
import java.util.List;
import online.school.domain.Student;
import online.school.utils.SqlHelp;

public class StudentDao implements IStudentDao{

        @Override
        public int addStudent(String sql, String... args) {
                return new SqlHelp().executeUpdate(sql,args);
               
        }

        @Override
        public int delStudent(String sql, String... args) {
                return new SqlHelp().executeUpdate(sql,args);
        }

        @Override
        public Student findStudent(String sql, String... args) {
                ArrayList al = new SqlHelp().executeQuery(sql, args);
                        Object[] obj =(Object[]) al.get(0);
                        Student student = new Student();
                        student.setStu_id((String) obj[0]);
                        student.setStu_name((String) obj[1]);
                        student.setStu_addr((String) obj[2]);
                        student.setStu_spec((String) obj[3]);
                        student.setStu_dorm((String) obj[4]);
                        return student;
               
        }

        @Override
        public List<Student> getAllStudent(String sql) {

                ArrayList al = new SqlHelp().executeQuery(sql);
                return al;
        }

        @Override
        public int updateStudent(String sql, String... args) {
               
                return new SqlHelp().executeUpdate(sql, args);
               
        }

        
        
}
[/mw_shl_code]

stuManager.rar

507.45 KB, Download times: 0, Download credits: -1 prestige, -1 contribution

Selling Price:2 MB [Recording]  [purchase]





Previous:Recently, I am doing an online bookstore project, which is a registration function that has been done in the past few days
Next:C# version of the student management system
 Landlord| Posted on 11/20/2014 9:20:55 PM |
admin posted on 2014-11-20 21:13
It is recommended that the owner sell the source code of the attachment for 2 money

:victory:
Posted on 11/20/2014 9:13:20 PM |
It is recommended that the owner sell the source code of the attachment for 2 money
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com