數(shù)據(jù)庫選修課程管理系統(tǒng)_第1頁
數(shù)據(jù)庫選修課程管理系統(tǒng)_第2頁
數(shù)據(jù)庫選修課程管理系統(tǒng)_第3頁
數(shù)據(jù)庫選修課程管理系統(tǒng)_第4頁
數(shù)據(jù)庫選修課程管理系統(tǒng)_第5頁
已閱讀5頁,還剩39頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、package yangxu;import javaawt*;import javaawtevent*;import javaxswing*;import javax.swing.table.abstracttablemodel;import javaapplet.applet;import javaappletaudioclip;import java.io.import .malformedurlexception;import javaneturi;import javaneturl;import java.sql.*;import sunaudio.*;public class mai

2、n public static void main(string args) new login();七可file f= new file ( ”d :/音樂/logic .mid”); uri u =ftouri();url r = null;r = u.tourl();audioclip m=applet.newaudioclip(r); m.loop (); catch (malformedurlexception e) / todo auto-generated catch bloc eprintstacktrace ();class login extends jframejlabe

3、l llogin,ikeyzlloginlnform;jtextfield textlogin,textkey;jpasswordfield passfield;jbutton blogin,bcancel;choice identify;public login () settitle (”選修課程管理系統(tǒng)”);int width = getwidth();int height =getheight();int(toolkit.getdefault toolkit() .getscreensize () .width -width )/ 2;inth=(toolkit-getdefault

4、toolkit() getscreensize () .height-height)/ 2;setlocation (wa h);setlayout(new flowlayout(flowlayout.center. 100,25); llogininform=new jlmbel ( ”登陸身份:");identify = new choice();identify add (”學(xué)生");identify add (”教師"); identify .add (”管理員“); add(lloginlnform);add(identify);llogin=new j

5、labe丄(”賬號:”);add(llogin);textlogin=new jtextfield(n h z 7);add(textlogin);lkey=new jlabe丄(”密碼:”);add(ikey);passfield = new jpasswordfield(7);add(passfield);blogin=new jbutton ("背陸”);blogin addactionlistener (new actionlistener () public void actionperformed(actionevent e)boolean flag;if(identif

6、y.getselectedltem().equals(h 學(xué) 生 “)& & (textlogin gettext () ) equals (11 studentn ) char pass = passfield.getpmssword();for(int i =0;i<6;)if(passi=i+l)flag =true;else flag = false;break;if(flag = true)dispose ();new student () setvisible(true);if(identify.getselecteditem().equals(h 管 理 員

7、 ”)&&(textlogingettext () equals(nmanagerh) char pass = passfield.getpassword();for(int i =0;i<6;)if(passi=i+l)flag =true;else flag = false;break;if(flag = true)dispose ();new student () .setvisible(true); if(identify.getselectedltem()equals(n教 師“)&&(textlogingettext () equals ( n

8、teacherh) char pass = passfield.getpassword();for(int i =0;i<6;)if(passi=i+l)flag =true;else flag = false;break;if(flag = true)dispose ();new teacher () .setvisible(true);else settitle ( ”輸入的賬號或者密碼有誤,重新輸入”););bcancel=new jbutton (”退出”);bcancel.addactionlistener(new actionlistener()public void act

9、ionperformed(actionevent e)system.exit(0););add(blogin);add(bcancel);jpanel p=new jpanel();jlabel l=new jlabel();getlayeredpane() .add(lf new integer(integer.min_value); getcontentpane()add(p);pack () ;/窗口適應(yīng)組件大小setdefaultcloseoperation(jframeexit_on_close);setsize (400,250);setvisible(true);class st

10、udent extends jframe jbutton sselectcourse, sselectrcourselist,sreturn;public student()super ( n學(xué)生界面”);setlayout(new flowlayout(flowlayout.center, 100a 60); int width = getwidth();int height =getheight ();irrtw=(toolkit.getdefault toolkit() .getscreensize () .width -width )/ 2; inth=(toolkit.getdefa

11、ulttoo丄kit() .getscreensize () .height-height)/ 2;setlocation(wa h);sselec七。011匕$0 = new jbutton (”學(xué)生選課”);sselectcourseaddactionlistener(new actionlistenet()public void actionperformed(actionevent e) dispose();new sselectcourse () .setvisible(true););sselect = new jbutton(”選課查詢”);sselectaddactionlis

12、tener(new actionlistener ()public void actionperformed(actionevent e) dispose();new stuselect () setvisible(true););courselist = new jbutton(”課程歹ll表”);courselistaddactionlistener(new actionlistener ()public void actionperformed(actionevent e) new courselist () setvisible(true););add(sselectcourse);a

13、dd (sselect);add(courselist);sreturn = new jbutton ("返回前頁");sreturnaddactionlistener(new actionlistener()public void actionperformed(actionevent e) dispose();new login().setvisible(true););add(sreturn);setdefaultcloseoperation(jframeexit_on_close); setsize(400, 250);setvisible(true);public

14、 static void main(string args) new student ();class sselectcourse extends jframe jlabel lz m, a,p;jtextfield tf,tf1z tf2;jbutton jbuta rt,ud;public sselectcourse()super (”學(xué)生選課”);setlayout (new flowlayout (flowlayout. centerr s r 40); int width = getwidth();int height =getheight();intw(toolkit. getde

15、fau jltto o 丄 kit () . get screensize () .width -width ) / 2;int(toolkit.getdefauit toolkit() .getscreensize () .height-height) / 2; setlocation(w, h);a = new jlabe.(”);add(a);m = new jlabel ("請輸入你要添加的學(xué)號:”);add(m);tf = new jtextfield(h"z 7);add(tf);p = new jlabel (n請輸入你要添加的姓名:”);add(p);tfl

16、 = new jtextfield(”, 7);add(tfl);1 = new jlabel (m請輸入你要添加的課程號:“);add ;t f 2 = new jtextfield ('* n z 7);add(tf2);jbut = new jbutton ( ”確定”);jbut.addactionlistener(new actionlistener () public void actionperformed(actionevent e) connection conn = null;t rystringurl=n jdbc:oracle:thin:qlocalhost:1

17、521:orclh;string user = "system" ;/連接數(shù)據(jù)庫的用戶名string password = nyangxun;/連接數(shù)據(jù)庫的密碼 t可class . forname ( "oracle jdbc driver ” ) ; / 力li載驅(qū)動程序 catch (java.lang.classnotfoundexception el)el.printstacktrace();t ryconn = drivermanagerget connect ion(url, user, password) ;/與些指定的數(shù)據(jù)源建立連接catch (s

18、qlexception el) el.printstacktrace ();statement st;st = conncreatestatement();resultset rs;rs=st.executequery("select課禾呈表.coursename from 楊旭課程表 where courseld = h+t f 2 . gettext ()+");while(rsnext () system.out.printin(rs.getstring (1); st .executequery (ninsert into 楊旭.學(xué)生表 values("+

19、t f gettex t () + ” , ' "+tf 1 get text ()+”', ”+tf 2 gettext ()+*, * " + rs get string(l)+n1,null)”);system, out .print丄n (”成功”);st.close ();conn close();catch(sqlexception el) );ud = new jbutton ("修改”);udaddactionlistener(new actionlistener()public void actionperfornied (act

20、ionevent e) connection conn = null;trystringurl=” jdbc:oracle:thin:slocalhost:1521:orcl"string user = nsystem*1;/連接數(shù)據(jù)庫的用戶名string password = "yangxu” ;/連接數(shù)據(jù)庫tl勺密碼try class forname ( horacle . jdbc driver. oracledriver n ) ; / 力1載驅(qū)動程序 catch (java.langclassnotfoundexception el)elprintstacktra

21、ce();)tryconn = driverbdanager getcoacectiog (url, user, password) ;/與竺指定的數(shù)據(jù)源建立連接catch (sqlexception el)el.printstacktrace();statement st;st = conn.createstatement();resultset rs;rs=st. executequery ('*select課程. coursename from 楊旭.課程表 where courseld = n+tf2gettext ()+"”);while(rs.next()rs =

22、 st. executequery ( "update 楊旭.學(xué)生表 setsname= * n+tf1.gettext()+”',courseid=”+tf2gettext()+n,coursename = * n+rs.getstring (1)+"* where snum = n+tf gettext ()+”");system, out. print in (” 成功”);st.close ();conn close ();catch(sqlexception el);rt = new jbutton (njmr '*);addaction

23、listener(new actionlistener()public void actionperformed(actionevent e) dispose();new student()setvisible(true););add(jbut);add(ud);add(rt);setsize (300, 300); setvisible(true);class selectstu extends jframepublic selectstu() super ( n學(xué)生查詢”); mytable m=new mytable(); jtable t=new jtable(m);tsetprefe

24、rredscrollableviewportsize(new dimension (500, 70);jscrollpane s=new jscrollpane (t);add(s);int width = getwidth();int height =getheight();intw=(toolkit. getdefaujlttoo丄kit () .getscreensize () . width 一width ) / 2;int(toolkit.getdefauit toolkit() .getscreensize () .height-height) / 2;setlocation(w,

25、 h);setsize (500z 250);class mytable extends abstracttablemodelirrt p = 0;string stunum,stuname,courseld,coursename,coursescore;final string ccdunmn3mes= ”學(xué)號”,”姓名”,”課程號“,”課程” 分?jǐn)?shù)” ;object data=new object1005;public mytable()connection conn = null;trystringurl=11 jcibc : oracle : thin : localhost: 152

26、1: orcln ;string user = "system" ;/連接數(shù)據(jù)庫的用戶名string password = "yangxu” ;/連接數(shù)據(jù)庫j勺密碼try class forname ( "oracle . jdbe . driver . oracledriver n ) ; / 力口載驅(qū)動程序 catch ( javalangclassnotfoundexception e) eprintstacktrmce();tryconn = drivermanagerget connect ion(url, userz password) ;/

27、與竺指定的數(shù)據(jù)源建立連接catch (sqlexception e) e.printstacktrace();statement st;st = conncreatestatement();resultset rs;rs = st. exec ut equery ( n select 學(xué)生表from 楊 旭.學(xué)生表 where snum = " + stuselect. tf .gettext () +n,');system, out .printin (”成功”);while(rsnext () stunum=rs.getstring(1);stuname=rs.getst

28、ring(2);courseld = rs.getstring (3);coursename=rs.getstring(4);coursescore=rs.getstring (5);data p 0=stunum; dmtap1=stuname;dmta p 2=courseld; datap3=coursename;data p 4=coursescore; p+;stclose ();connclose ();catch(sqlexception e)public int getcolumncount()return columnnameslength;public int getrow

29、count()return data.length;public string getcolumnname(int col) return columnnamescol;public object getvalueat(int row,int col) return datarowcol;public void setvalueat(object value,int row,int col)int numrows=getrowcount();int numcols=gqt:columncount ();for(int i=0;i<numrows;i+)for(int j=0;j<n

30、umcols;j+)system out.print(” ”+dai j);class courselist extends jframe public courselist() super (”課程列表”);mytable m=new mytable ();jtable t=new jtable(m);tsetpreferredscrollableviewportsize(newdimension (500,70);jscrollpane s=new jscrollpane (t);add(s);int width = getwidth();int height =getheight ();

31、intw=(toolkit. getdefaujlttoo丄kit () getscreensize () . width -width ) / 2;inth=(toolkit.getdefault toolkit() .getscreensize() .height-height) / 2; setlocation(wz h);setsize (500,250);class mytable extends abstracttablemodelint p = 0;string courseld,coursename,tidz tname;final string columnnames= h課

32、程號”,”課程名“,”教師工號教師姓 名object 1 data=new object100 4;public mytable()connection conn = null;trystring url = n jdbc:oracle:thin:glocalhost:1521:orcln;string user = "system0 ;/連接數(shù)據(jù)庫的用戶名string password = nyangxun ; /連接數(shù)據(jù)庫的密碼try class . forname ( noracle jdbc driver . oracledriver " ) ; / 力口載9區(qū)動程

33、序 catch (javalang.classnotfoundexception e) e.printstacktrace ();tryconn = drivermanagerget connect ion(url, user, password) ;/與竺指定的數(shù)據(jù)源建立連接catuh (sqlexception e) e.printstacktrace();statement st;st = conncreatestatement();resultset rs;rs = st .executequery ( nselect 課程表宀教!)帀表.tid,教師表.tname from楊旭課程表

34、,楊旭教師表 where教師表.courseld =課程 表courseld n);sys tem. out .pr in tin ("成功”);while(rsnext () system, out: .printin ("成功”);courseid=rs.getstring(1);coursename=rs.getstring (2);tid = rs.getstring (3);tname=rs.getstring(4);datap0=courseld;data p 1=coursename;datap2=tid;datap 3=tname;p+;stclose ()

35、;connclose ();catch(sqlexception e)public int getcolumncount()return columnnameslength;public int getrowcount()return datalength;public string getcolumnname(int col)return columnnamescol;public object getvalueat(int row,int col)return datarowcol;public void setvalueat(object value,int row,int col)in

36、t numrows=getrowcount();int numcols=getcolumncount();for(int i=0;i<numrows;i+)for(int j=0;j<numcols;j+)system.out.print(n n+datai j );class teacher extends jframejbutton tselect,tinsert;jbutton sreturn;public teacher() settitle (h教師界面”);setlayout (new flowlayout (flowlayout centerr 100, 60); i

37、nt width = getwidth();int height =getheight();intw=(toolkit. getdefaujlttoo丄kit () .getscreensize () . width -width ) / 2;inth=(toolkit.getdefault toolkit() .getscreensize () .height-height) / 2; setlocation(w, h);tselect = new jbutton (1 喳詢教師”);tselect.addactionlistener(new actionlistener()public v

38、oid actionperformed(actionevent e)dispose ();new tcselect () .setvisib丄e(true););t insert=new jbutton (力口成績”);tinsert.addactionlistener(new actionlistener()public void actionperformed(actionevent e)dispose ();new tinsert () .setvisible(true););add(tselect);add(tinsert);sreturn = new jbutton ( nn );s

39、return.addactionlistener(new actionlistener () public void actionperformed(actionevent e) dispose ();new login().setvisible(true););add(sreturn);setdefauitcloseoperation(jframe.exit_on_close); setsize(400,250);setvisible(true);public static void main(string args)new teacher();class selecttea extends

40、 jframepublic selecttem()super ( »教師査詢”);mytable m=new mytable();jtable t=new jtabl©(m);tsetpreferredscrollableviewportsize(newdimension(500,70);jscrollpane s=new jscrollpane(t);add (s);int width = getwidth();int height =getheight();intw=(toolkit.getdefault toolkit() .getscreensize () .wid

41、th -width )/ 2;inth=(toolkit.getdefault toolkit() .getscreensize () .height-height)/ 2;setlocation(wz h);setsize(500,250);class mytable extends abstracttablemodelint p = 0;string teanum,teaname,courseld,coursename;final string columnnames= n教師工號”,”姓名”,”課程號” j* 課程object1 data=new object1005; public m

42、ytable()connection conn = null;urltrystringn jdbc:oracle:thin:localhost:1521:orcln;string user = "system1'/連接數(shù)據(jù)庫的用戶名st ring password = "yangxu” ;/連扌妾數(shù)據(jù)庫白勺密碼 try class forname ( "oracle . jdbe . driver . oracledriver n ) ; / 力口載驅(qū)動程序 catch ( javalangclassnotfoundexception e) eprints

43、tacktrmce();conn = drivermanagerget connect ion(url, userz password) ;/與竺指定的數(shù)據(jù)源建立連接catch (sqlexception e) e.printstacktrace();statement st;st = conncreatestatement();resultset rs;rs = st. exec ut equery ( n select 教師表.六 from 楊旭教師表 where tld = h+tcselec t get text () + ,n);system, out .printin (”成功”)

44、;while(rsnext () teanum=rs.getstring (1);teaname=rs.getstring(2);courseld = rs.getstring(3);coursename=rs.getstring(4);data p 0=teanum; datap1=teaname;data p 2=courseld;data p 3=coursename;p+;stclose ();connclose ();catch(sqlexception e)public int getcolumncount()return columnnameslength;public int

45、getrowcount()return data.length;public string getcolumnname(int col)return columnnamescol;public object getvalueat(int rowa int col) return datarowcol;public void setvalueat(object value,int row,int col)int numrows=getrowcount ();int rmmcols=getcolumncount();for(int i=0;i<numrows;i+)for(int j=0;j

46、<numcols;j+)system out.print(” n+datai j);class tinsert extends jframejlabel 1,m,cz a;jtextfield tfz tf1z tf2;jbutton jbut,rt;public tinsert()super ("添加學(xué)生成績”);setlayout (new flowlayout (flowlayout center. 10,40); int width = getwidth();int height =getheight();intw=(toolkit.getdefault toolkit

47、() .getscreensize() .width -width )/ 2;inth=(toolkit.getdefault tool kit() .getscreensize () .height-height) / 2; setlocation(wz h);a=new jlabel (*"*);add(a);l=new jlabel ( u請輸入你要添加的學(xué)號:”);add(l);t f=new jtextfield (*"* z 7);add (tf);c=new jlabel (*'請輸入你要添加的課程號:”);add(c);t f l=new jtext

48、field (, 7);add(tf1);l=new jlabel (n請輸入你要添加的成績:”); add(l);t f 2=new jtextfield ('* n , 7);add (tf2);jbut=new jbutton ( ”確定”);jbut.addactionlistener(new actionlistener() public void actionperformed(actionevent e) connection conn = null;trystringurl=n jdbc:oracle:thin:localhost:1521:orcln;string u

49、ser = ”system”; /連接數(shù)據(jù)庫的用戶名 st ring password = "yangxu” ;/連接數(shù)據(jù)庫 a 勺密碼 try class forname ( noracle jdbc. driver. oracledriver n ) ; / 口載9區(qū)動程序 catch (java.lang.classnotfoundexception el)elprintstacktrace ();)t ryconn = drivermanagergetconnection(url, user, password) ;/與竺指定的數(shù)據(jù)源建立連接catch (sqlexcepti

50、on el) el.printstacktrace();statement st;st = conncreatestatement();resultset rs;rs=st. executequery ('*select課 程. coursename from 楊旭.課程表 where courseld = n+t f 1. get text () + h ");while(rsnext () system.out.printin(rs.getstring(1); st. executequery ( nupdate 楊旭學(xué)生表set score = h+tf2.gettex

51、t()+" where snum=n+tf.gettext()+" and courseld=n+tf 1.gettext ()+");system, out. print in ("成功");stclose ();corm close ();catch(sqlexception el);rt = new jbutton("返冋”);rt.addactionlistener(new actionlistener() public void actionperformed(actionevent e) dispose ();new te

52、acher () .setvisible(true););add(jbut);add(rt);setsize(300,300); setvisible(true);class admin extends jframe jbutton at,as,ac;jbutton sreturn;public admin()super ( »管理員界面”);setlayout (new flowlayout (flowlayout. center, 100, 60);int width = getwidth();int height =getheight ();intw=(toolkit.getd

53、efault toolkit() .getscreensize() .width -width )/ 2;inth=(toolkit.getdefault tool kit() .getscreensize () .height-height) / 2; setlocation(wf h);at = new jbutton ( ”教師”);ataddactionlistenet(new actionlistener()public void actionperformed(actionevent e) dispose ();new ateacher().setvisible(true););a

54、s = new jbutton ("學(xué)生”);asaddactionlistener(new actionlistener()public void actionperformed(actionevent e) dispose ();new astudent()setvisible(true););ac = new jbutton("課程“);ac.addactionlistener(new actionlistener()public void actionperformed(actionevent e) dispose ();new acourse().setvisible(true););add(at);add(as);add(ac);sreturn = new jbutton ("返冋”);sreturn.addactionlistener(new actionlistener() public void actionperformed(actionevent

溫馨提示

  • 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

提交評論