版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、數(shù)據(jù)庫程序設(shè)計大作業(yè)班級:2012級軟件外包服務(wù)一班學(xué)號:201215140117姓名:。°。時間:2013-6-191-功能描述1.1功能簡介用swing做出圖形化界而形式,實現(xiàn)數(shù)據(jù)庫的增刪改査把員工表跟部門表連接起來,實現(xiàn)數(shù)據(jù)的增加,刪除,修改,查找。1.2實現(xiàn)步驟(1)安裝好虛擬機(jī),并在其下確認(rèn)oracle己安裝成功(可以在dos下輸入相關(guān)命令來檢查是否安裝成功)。(2)在網(wǎng)絡(luò)中心修改pc機(jī)上的VMwareNetworkAdapter的IP、子網(wǎng)頁碼(默認(rèn))、網(wǎng)關(guān)。(3)修改虛擬機(jī)的IP、網(wǎng)掩碼(默認(rèn))、網(wǎng)關(guān),確保PC機(jī)上的網(wǎng)關(guān)和虛擬機(jī)的IP致。(在控制面板網(wǎng)絡(luò)和共享中心本地連
2、接3一屬性中,修改IP、網(wǎng)掩碼)(4)在PC機(jī)的dos命令控制臺ping虛擬機(jī)的IP,確保正常,能ping通(即將虛擬機(jī)內(nèi)夕卜ping通)。(5)配置好虛擬機(jī)下的oracle的數(shù)據(jù)庫和監(jiān)聽。(6)在eclipse中編寫相關(guān)代碼,并用jtable實現(xiàn)圖形化界面,用以實現(xiàn)與數(shù)據(jù)庫的連接和操作數(shù)據(jù)庫等功能。(7)在eclipse中導(dǎo)入數(shù)據(jù)庫的驅(qū)動。(8)運(yùn)行eclipse,査看運(yùn)行結(jié)果。2.核心代碼2.11.數(shù)據(jù)庫連接packageorg.lxh.mfb.dbc;unpoitjava.sql.Comiectiou;mipoitjava.sql.DnvefManagei;unpoitjava.sql.
3、ResultSet;importjava.sql.SQLException;importjava.sql.Statement;publicclassDatabaseComiectionpublicstaticvoidniaui(StiingaigsComiectionconn=null;Statementstmt=null;ResultSetis=null;tryClass.fbiNaiiie(noiaclejdbc.diivei.OiacleDnveiM;Snmgml=Mjdbc:oracle:thin:2&1521/WFJ"coim=DriveiMa
4、nager.getConiiection(ufLm1hu,m1hu;stmt=coim.cieateStatement(;Suingsql="select*fiomdepaitmentsM;is=stmt.executeQueiy(sql;while(rs.next(Systeni.out.pnnt(is.getInt(ndepaitment_idM;System.out.pimtCV;System.out.print(rs.getStimg(ndepaitment_namefl;System.out.pimtCV;Systemoi】tpimtUsgetIiHCmaiiagei_ic
5、r;System.out.pimtCV;System.out.print(rs.getIiit(Hlocation_idn;Systeni.out.pnntln(;catch(ClassNotFoundExceptionee.pnntStackTiace(;catch(SQLExceptionee.pnntStackTiace(;filiallytryif(is!=nullrs.close(;if(stmt!=nullstm匚close(;if(comi!=nullcoim.close(;catch(SQLExceptione/TODOAuto-geneiatedcatchblocke.pnn
6、tStackTiace(;2生成getset方法packageedu;publicclassCountryprivateStringdepartment_id;privateStringdepartment_name;privateStringarea;privateStringpopulation;publicStringgetdepartment_id(returndepartment_id;publicvoidsetdepartment_id(Stringdepartment_namethisname二department_id;publicStringgetdepartment_nam
7、e(returndepartment_name;publicvoidsetdepartment_name(Stringdepartment_namethisdepartnient_naine二department_name;publicStringgetmanager_id(returnmanager_id;publicvoidsetmanager_id(Stringmanager_idthismanagei'id二manager_id;publicStringgetlocation_id(returnlocation_id;publicvoidsetlocation_id(Strin
8、glocation_idnthislocation_id二location_id;3實現(xiàn)方法packagetuxmgliua;unpoitjava.awt.Color;mipoitjava.awt.event.ActionEvent;unpoitjava.aw匸even匸AchonListenei;mipoitjava.io.Serializable;unpoitjava.sql.DfiveiManagei;importjava.sql.ResultSet;mipoitjava.util.AiiayList;mipoitjava.util.List;mipoitjavax.swing.JBut
9、ton;mipoitjavax.swiiig.JFiame;unpoitjavax.swmg.JLabel;mipoitjavax.swing.JSciollPane;unpoitjavax.swing.JTable;mipoitjavax.swing.JTextField;unpoitjavax.swing.table.DefaultTableModel;unpoitjava.awt.event.MouseAdapter;unpoitjava.awt.event.MouseEvent;publicclassAppStiidentextendsJFrameprivateJTextFieldde
10、paitment_idField;privateJTextFielddepaitment_nameField;privateJTextFieldmanagei_idField;privateJTextFieldlocation_idField;privateJTabletable;privateDefaultTableModelmodel;privateStfingcolunms=Mdepaitment_id,udepaitment_name,nnianagei_idu,nlocation_idn;privateListdata;privateStudenttmp;publicAppStiid
11、ent(data=newAiiayList(;getContentPane(.setLavout(null;JLabellblemplovee=newJLabelCdepaitmeiH_id"lblemployee.setBounds(12,10.220,13;getContentPane(.add(lblemployee;depaitment_idFleld=newJTextField(;depailment_idField.setBounds(100,7,96,19;getContentPane(.add(depaitment_idField;depaitmencidField.
12、setColunuis(10;JLabellblAge=newJLabelCdepamneiH_iiame”;lblAge.setBounds(252,10,220,13;getContentPane(.add(lblAge;depaitmencnameField=newJTextField(;depaitment_nameFleld.setBounds(365,7、96.19;getContentPaiie(.add(depaitment_nameField;department_nameField.setColuniiis(l0;JLabellblStuno=newJLabel(”mana
13、gei_icT;lblStuno.setBounds(12,36,220,13;getContentPane(.add(lblStuno;managei_idField=newJTextField(;managei_idFleld.setColumns(l0;managei_idField.setBounds(100,33,96,19;getContentPaiie(.add(managei_idField;JLabellblClass=newJLabel(,location_idn;lblClass.setBounds(252,36,220,13;getContentPane(.add(lb
14、lClass;location_idField=newJTextField(;location_idFleld.setColunms(l0;location_idFleld.setBounds(365,33,96,19;getContentPane(.add(location_idField;JButtonbtnAdd=newJButton(M增加”;btiiAdd.addActionListenei(newActionListenei(publicvoidactionPeifbimed(ActioiiEventeadd(;btiiAdd.setBounds(75,59,77,21;getCo
15、ntentPane(.add(btiiAdd;JButtonbtnDel=newJButton("刪除";btiiDel.addActionListenei(newActioiiListenei(publicvoidactionPeifdimed(ActioiiEventedel(;btnDel.setBounds(180,59,77,21;getContentPane(.add(btiiDel;JButtonbtnUpdate=newJButton("更新”;btnUpdate.addActionListenei(newActioiiListenei(publi
16、cvoidactionPeifdimed(ActioiiEventeupdate(;btnUpdate.setBounds(280,59,77,21;getContentPane(.add(btnUpdate;JButtonbtnFind=newJButton("查找"btiiFind.addActionListenei(newActionListenei(publicvoidactionPeifdimed(ActioiiEventebtnFind.setBounds(380,59,77,21;getContentPane(.add(btiiFind;model=newDe
17、faultTableModel(colunms,0;table=newJTable(model;table.addMouseListenei(newMouseAdapter(publicvoidmouseClicked(MouseEventemtlow=table.getSelectedRow(;depaitment_idField.setText(Stimgtable.getValueAt(iow,0;depaitmencnameField.setText(Stinigtable.getValueAt(iow,2;managei.idFleld.setText(Stiingtable.get
18、ValueAt(iow,3;location_idFleld.setText(Stiingtable.getValueAt(iow,4;tmp=getlnput(;JSciollPanesciollPane=newJSciollPane(table;scrollPane.setBounds(12,100,571,248;getContentPane(.add(sciollPane;setDefaultCloseOpeiation(EXIT_ON_CLOSE;setLocatioiiRelativeTo(null;setLocation(350,200;setSize(601,380;setRe
19、sizable(false;setVisible(tme;privateStudentgetbiput(Studentstu=newStudent(;sm.depaitment_id=depaitment_idField.getText(;sm.depaitmenoiame=depaitment_nameField.getText(;snLnianagei_id=nianagei_idField.getText(;sni.location_id=location_idField.getText(;reuuiistu;privatevoidadd(data.add(getlnput(;sliow
20、Table(;privatevoiddel(for(niti=0;i<data.size(;i+if(tmp.equals(data.get(idata.remove(i;bieak;sliowTable(;privatevoidupdate(Studentstu=getbiput(;for(inti=0;i<data.size(;i十十if(tmp.equals(data.get(idata.iemove(i;data.add(i,stu;break;sliowTable(;privatevoidfind(removeRows(;Studentstu=getbiput(;for(
21、inti=0;i<data.size(;i十十Suidenttmp=(Studentdata.get(i;if(tmp.equals(stumodel.addRow(tmp.toAiTay(;break;privatevoidshowTable(iemoveRows(;for(niti=0;i<data.size(;i+Studentstu=(Studentdata.get(i;model.addRow(sni.toAiiay(;privatevoidiemoveRows(wlule(model.getRowCount(>0model.iemoveRow(0;publicst
22、aticvoidmam(StnngaigsnewAppStudent(;classSuidentunplementsSerializablepublicSuingdepaitment_id;publicSuingdepaitment_nanie;publicSuingmanagei_id;publicSuinglocation_id;publicbooleanequals(Objectobjreturnequals(Snidentobj;publicbooleanequals(Studentobjbooleanisdepaitment_id=tine;if(obj.depaitment_id!=null&&?HH.equals(obj.depaitmencidisdepaitment_id=depanmeiit_id.equals(obj.depaitment_id;booleanisdepaitment_name=tme;if(obj.depaitment_name!=null&&!,M,.equals(obj.depaitment_nanieisdepaitment_name=depaitment_name.equals(obj.depaitmencname;bo
溫馨提示
- 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025屆河南省洛陽名校高二物理第一學(xué)期期末考試模擬試題含解析
- 2025屆江蘇省金陵中學(xué)高三物理第一學(xué)期期中經(jīng)典模擬試題含解析
- 河南省名校聯(lián)盟2025屆物理高三上期末考試試題含解析
- 重慶三十二中學(xué)2025屆高二物理第一學(xué)期期中監(jiān)測試題含解析
- 遼寧省遼源市金鼎高級中學(xué)2025屆物理高一第一學(xué)期期中經(jīng)典模擬試題含解析
- 內(nèi)蒙古烏蘭察布市集寧地區(qū)2025屆物理高二第一學(xué)期期末達(dá)標(biāo)測試試題含解析
- 江蘇省大豐市實驗初級中學(xué)2025屆物理高二上期末學(xué)業(yè)質(zhì)量監(jiān)測模擬試題含解析
- 2025屆吉林省物理高二第一學(xué)期期中調(diào)研模擬試題含解析
- 陜西省咸陽市武功縣2025屆高二物理第一學(xué)期期中聯(lián)考試題含解析
- 廣州市嶺南中學(xué)2025屆物理高二上期末質(zhì)量跟蹤監(jiān)視試題含解析
- 果蔬機(jī)械冷藏課件2
- 拼音復(fù)習(xí)-拼音轉(zhuǎn)盤課件
- 項目進(jìn)度管理培訓(xùn)(-)課件
- 醫(yī)院合同管理辦法
- 2023年度小區(qū)業(yè)主大會會議召開工作方案
- 高考語文 如何讀懂詩歌 課件(32張PPT)
- 中壓交聯(lián)電纜電纜正、負(fù)和零序計算
- 3C戰(zhàn)略三角模型
- 高標(biāo)準(zhǔn)農(nóng)田建設(shè)示范工程質(zhì)量管理體系與措施
- 學(xué)生頂崗實習(xí)安全教育課件
- 公司組織架構(gòu)圖模板課件
評論
0/150
提交評論