java課程設(shè)計+Mysql--小型學(xué)生管理系統(tǒng)(無窗體)_第1頁
java課程設(shè)計+Mysql--小型學(xué)生管理系統(tǒng)(無窗體)_第2頁
java課程設(shè)計+Mysql--小型學(xué)生管理系統(tǒng)(無窗體)_第3頁
java課程設(shè)計+Mysql--小型學(xué)生管理系統(tǒng)(無窗體)_第4頁
java課程設(shè)計+Mysql--小型學(xué)生管理系統(tǒng)(無窗體)_第5頁
已閱讀5頁,還剩13頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、package Student;import java.sql.*;import java.util.*;public class AdEnter /* * param args * throws Exception */public AdEnter() throws ExceptionSystem.out.println("歡迎使用小型學(xué)生管理系統(tǒng)!");System.out.println("請根據(jù)提示進(jìn)行操作!");System.out.println("");System.out.println("1.增加學(xué)生信息&

2、quot;);System.out.println("2.查找學(xué)生信息");System.out.println("3.修改學(xué)生信息");System.out.println("4.刪除學(xué)生信息");System.out.println("5.顯示所有學(xué)生信息");System.out.println("6.排序?qū)W生信息");System.out.println("請輸入您的選擇:");Scanner c = new Scanner(System.in);int a = c.

3、nextInt();switch(a)case 1 : new add();break;case 2 : new find();break;case 3 : new change();break;case 4 : new del();break;case 5 : new show();break;case 6 : new sort();break;default :System.out.println("請輸入正確選項!");new AdEnter();break;public static void main(String args) throws Exception /

4、 TODO Auto-generated method stubAdEnter h = new AdEnter();package Student;import java.sql.Connection;import java.sql.SQLException;import java.sql.Statement;import java.util.Scanner;public class add Statement stmt;public int x = 0;public add() throws Exceptionchar m;String id;String name;String col;S

5、tring cl;String math;String os; String java;doScanner c = new Scanner(System.in);System.out.print("請輸入學(xué)生學(xué)號:");id = c.nextLine();System.out.println("n");System.out.print("請輸入學(xué)生姓名:");name = c.nextLine();System.out.println("n");System.out.print("請輸入學(xué)生學(xué)院:&quo

6、t;);col = c.nextLine();System.out.println("n");System.out.print("請輸入學(xué)生班級:");cl = c.nextLine();System.out.println("n");System.out.print("請輸入學(xué)生數(shù)學(xué)成績:");math = c.nextLine();System.out.println("n");System.out.print("請輸入學(xué)生os成績:");os = c.nextLine(

7、);System.out.println("n");System.out.print("請輸入學(xué)生java成績:");java = c.nextLine();System.out.println("n");Connection conn = DBUtil.getDBConn();String sql = "create table IF NOT EXISTS stus(stuid int, stuname varchar(20), stucollege varchar(20)," +"stuclass v

8、archar(20), stumath decimal, stuos decimal, stujava decimal)"Statement stmt = conn.createStatement();stmt.executeUpdate(sql);stmt = conn.createStatement();String sql1 = "INSERT INTO stus VALUES("+"'"+id+"'"+","+"'"+name+"'&q

9、uot;+","+"'"+col+"'"+","+"'"+cl+"'"+","+"'"+math+"'"+","+"'"+os+"'"+","+"'"+java+"'"+")"int efr = st

10、mt.executeUpdate(sql1);stmt.close();if(efr > 0)System.out.println("學(xué)生信息添加成功!");x+;System.out.println("是否繼續(xù)錄入學(xué)生信息?(y/n)");m = c.next().charAt(0);while(m = 'y' | m = 'Y');new AdEnter();package Student;import java.sql.Connection;import java.sql.SQLException;import

11、 java.sql.Statement;import java.util.Scanner;public class change private static String id;private static String id1;private static String name;private static String col;private static String cl;private static String math;private static String os; private static String java; public change() throws Ex

12、ception System.out.println("歡迎使用簡易學(xué)生信息管理系統(tǒng)修改功能n");Scanner c = new Scanner(System.in);System.out.println("請輸入要修改信息的學(xué)生學(xué)號:");id1 = c.nextLine();System.out.println("請輸入學(xué)生學(xué)號:");id = c.nextLine();System.out.println("請輸入學(xué)生姓名:");name = c.nextLine();System.out.println(

13、"請輸入學(xué)生學(xué)院:");col = c.nextLine();System.out.println("請輸入學(xué)生班級:");cl = c.nextLine();System.out.println("請輸入學(xué)生數(shù)學(xué)成績:");math = c.nextLine();System.out.println("請輸入學(xué)生os成績:");os = c.nextLine();System.out.println("請輸入學(xué)生java成績:");java = c.nextLine();Connection

14、conn = DBUtil.getDBConn();String sql = "update stus set stuid = "+"'"+id+"'"+",stucollege = "+"'"+col+"'"+", stuclass = "+"'"+cl+"'"+", stumath = "+"'"+math+"

15、;'"+"," +"stuos = "+"'"+os+"'"+", stujava = "+"'"+java+"'"+" where stuid = "+"'"+id1+"'" Statement stmt = conn.createStatement();stmt.executeUpdate(sql);stmt.close();S

16、ystem.out.println("修改成功!");new AdEnter(); package Student;import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLException;import java.sql.Statement;public class DBUtil private static Connection conn;statictry Class.forName("com.mysql.jdbc.Driver");conn = Dri

17、verManager.getConnection("jdbc:mysql:/localhost:3306/stu", "root", "123456"); catch (Exception e) e.printStackTrace();public static Connection getDBConn()return conn;package Student;import java.sql.Connection;import java.sql.SQLException;import java.sql.Statement;import

18、 java.util.Scanner;public class del private static String name;Statement stmt;/* * param args * throws Exception */public del() throws Exception / TODO Auto-generated method stubSystem.out.println("歡迎使用簡易學(xué)生信息管理系統(tǒng)刪除功能n");Scanner c = new Scanner(System.in);System.out.println("請輸入學(xué)生姓名:&q

19、uot;);name = c.nextLine();Connection conn = DBUtil.getDBConn();tryString sql = "delete from stus where stuname = "+"'"+name+"'"stmt = conn.createStatement();stmt.executeUpdate(sql);stmt.close();catch(SQLException e)/ TODO Auto-generated catch blocke.printStackTr

20、ace();finallySystem.out.println("刪除成功!");new del();new AdEnter();package Student;import java.sql.Connection;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.util.Scanner;public class find_stuid public find_stuid() throws Exception System.out.prin

21、tln("請輸入您要查找的學(xué)生學(xué)號:");Scanner c = new Scanner(System.in);String id = c.nextLine();Connection conn = DBUtil.getDBConn();tryString sql = "select * from stus where stuid = '"+id+"'"Statement stmt = conn.createStatement();ResultSet rs = null;rs = stmt.executeQuery(sq

22、l);while(rs.next() System.out.println("學(xué)號:" + rs.getString("stuid"); /引號里面寫上你的數(shù)據(jù)庫表的列名 System.out.println("姓名:" + rs.getString("stuname"); /引號里面寫上你的數(shù)據(jù)庫表的列名 System.out.println("學(xué)院:" + rs.getString("stucollege");/引號里面寫上你的數(shù)據(jù)庫表的列名 System.out.pri

23、ntln("班級:" + rs.getString("stuclass"); System.out.println("高數(shù)成績:" + rs.getString("stumath"); System.out.println("os成績:" + rs.getString("stuos"); System.out.println("java成績:" + rs.getString("stujava"); rs.close();catch(SQ

24、LException e)/ TODO Auto-generated catch blocke.printStackTrace();finally/System.out.println("查無此人!");new AdEnter();package Student;import java.sql.Connection;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.util.Scanner;public class find_stuname

25、 public find_stuname() throws ExceptionSystem.out.println("請輸入您要查找的學(xué)生姓名:");Scanner c = new Scanner(System.in);String name = c.nextLine();Connection conn = DBUtil.getDBConn();tryString sql = "select * from stus where stuname = '"+name+"'"Statement stmt = conn.cre

26、ateStatement();ResultSet rs = null;rs = stmt.executeQuery(sql);while(rs.next()System.out.println("學(xué)號:" + rs.getString("stuid"); /引號里面寫上你的數(shù)據(jù)庫表的列名 System.out.println("姓名:" + rs.getString("stuname"); /引號里面寫上你的數(shù)據(jù)庫表的列名 System.out.println("學(xué)院:" + rs.getStr

27、ing("stucollege"); /引號里面寫上你的數(shù)據(jù)庫表的列名 System.out.println("班級:" + rs.getString("stuclass"); System.out.println("高數(shù)成績:" + rs.getString("stumath"); System.out.println("os成績:" + rs.getString("stuos"); System.out.println("java成績:&qu

28、ot; + rs.getString("stujava"); rs.close();catch(SQLException e)/ TODO Auto-generated catch blocke.printStackTrace();finallynew AdEnter();package Student;import java.util.Scanner;public class find public find() throws ExceptionSystem.out.println("歡迎使用簡易學(xué)生信息管理系統(tǒng)查找功能" +"n"

29、);System.out.println("-");System.out.println("1.按學(xué)號進(jìn)行查找");System.out.println("2.按姓名進(jìn)行查找"+"n");System.out.println("請輸入您的選擇:");Scanner c = new Scanner(System.in);int a = c.nextInt();switch(a)case 1 : new find_stuid();break;case 2 : new find_stuname();b

30、reak;default : System.out.println("請輸入正確選擇!");new find();break;package Student;import java.sql.Connection;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;public class show public show() throws ExceptionConnection conn = DBUtil.getDBConn();tryString sql = &q

31、uot;select * from stus"ResultSet rs = null;Statement stmt = conn.createStatement(); rs = stmt.executeQuery(sql); while(rs.next() System.out.println("學(xué)號:" + rs.getString("stuid"); /引號里面寫上你的數(shù)據(jù)庫表的列名 System.out.println("姓名:" + rs.getString("stuname"); /引號里面寫上

32、你的數(shù)據(jù)庫表的列名 System.out.println("學(xué)院:" + rs.getString("stucollege"); /引號里面寫上你的數(shù)據(jù)庫表的列名 System.out.println("班級:" + rs.getString("stuclass"); System.out.println("高數(shù)成績:" + rs.getString("stumath"); System.out.println("os成績:" + rs.getString("stuos"); System.out.println("java成績:" + rs.getString("stujava"); rs.close();catch(SQLException e)/ TODO Auto-generated catch blocke.printStackTrace();finally/System.out.println("表中沒有學(xué)生信息!");new AdEnte

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論