版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、數(shù)據(jù)庫(kù)程序設(shè)計(jì)大作業(yè)班級(jí):2012級(jí)軟件外包服務(wù)一班學(xué)號(hào):201215140117姓名: 。時(shí)間:2013-6-19 1功能描述1.1 功能簡(jiǎn)介用swing做出圖形化界面形式,實(shí)現(xiàn)數(shù)據(jù)庫(kù)的增刪改查把員工表跟部門表連接起來(lái),實(shí)現(xiàn)數(shù)據(jù)的增加,刪除,修改,查找。1.2 實(shí)現(xiàn)步驟(1)安裝好虛擬機(jī),并在其下確認(rèn)oracle已安裝成功(可以在dos下輸入相關(guān)命令來(lái)檢查是否安裝成功)。(2)在網(wǎng)絡(luò)中心修改pc機(jī)上的VMware Network Adapter的IP、子網(wǎng)頁(yè)碼(默認(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命令控制臺(tái)ping虛擬機(jī)的IP,確保正常,能ping通(即將虛擬機(jī)內(nèi)外ping通)。(5)配置好虛擬機(jī)下的oracle的數(shù)據(jù)庫(kù)和監(jiān)聽。(6)在eclipse中編寫相關(guān)代碼,并用jtable實(shí)現(xiàn)圖形化界面,用以實(shí)現(xiàn)與數(shù)據(jù)庫(kù)的連接和操作數(shù)據(jù)庫(kù)等功能。(7)在eclipse中導(dǎo)入數(shù)據(jù)庫(kù)的驅(qū)動(dòng)。(8)運(yùn)行eclipse,查看運(yùn)行結(jié)果。2. 核心代碼2.11. 數(shù)據(jù)庫(kù)連接public class DatabaseConnection public static void main(String args Connection co
3、nn = null;Statement stmt = null;ResultSet rs = null;try conn = DriverManager.getConnection(url, "hr", "hr"stmt = conn.createStatement(;String sql = "select * from departments"rs = stmt.executeQuery(sql;while (rs.next( catch (ClassNotFoundException e e.printStackTrace(;
4、catch (SQLException e e.printStackTrace(; finally try if (rs != null rs.close(;if (stmt != null stmt.close(;if (conn != null conn.close(; catch (SQLException e / TODO Auto-generated catch blocke.printStackTrace(;2. 生成get set方法package edu;public class Country private String department_id;private Stri
5、ng department_name;private String area;private String population;public String getdepartment_id( return department_id;public void setdepartment_id(String department_name = department_id;public String getdepartment_name( return department_name;public void setdepartment_name(String departmen
6、t_name this.department_name = department_name;public String getmanager_id( return manager_id;public void setmanager_id(String manager_id this.manager_id= manager_id;public String getlocation_id( return location_id;public void setlocation_id(String location_idn this.location_id = location_id;3實(shí)現(xiàn)方法pac
7、kage tuxinghua;public class AppStudent extends JFrameprivate JTextField department_idField;private JTextField department_nameField;private JTextField manager_idField;private JTextField location_idField;private JTable table;private DefaultTableModel model;private String columns = "department_id&
8、quot;, "department_name", "manager_id", "location_id"private List data;private Student tmp; public AppStudent( data = new ArrayList(;getContentPane(.setLayout(null;JLabel lblemployee = new JLabel("department_id"lblemployee.setBounds(12, 10, 220, 13; getContent
9、Pane(.add(lblemployee;department_idField = new JTextField(;department_idField.setBounds(100, 7, 96, 19; getContentPane(.add(department_idField;department_idField.setColumns(10;JLabel lblAge = new JLabel("department_name"lblAge.setBounds(252, 10, 220, 13;getContentPane(.add(lblAge;departmen
10、t_nameField = new JTextField(;department_nameField.setBounds(365, 7, 96, 19;getContentPane(.add(department_nameField;department_nameField.setColumns(10;JLabel lblStuno = new JLabel("manager_id"lblStuno.setBounds(12, 36, 220, 13;getContentPane(.add(lblStuno;manager_idField = new JTextField(
11、;manager_idField.setColumns(10;manager_idField.setBounds(100, 33, 96, 19;getContentPane(.add(manager_idField;JLabel lblClass = new JLabel("location_id"lblClass.setBounds(252, 36, 220, 13;getContentPane(.add(lblClass;location_idField = new JTextField(;location_idField.setColumns(10;location
12、_idField.setBounds(365, 33, 96, 19;getContentPane(.add(location_idField;JButton btnAdd = new JButton("增加"btnAdd.addActionListener(new ActionListener( public void actionPerformed(ActionEvent e add(;btnAdd.setBounds(75, 59, 77, 21; getContentPane(.add(btnAdd;JButton btnDel = new JButton(&quo
13、t;刪除"btnDel.addActionListener(new ActionListener( public void actionPerformed(ActionEvent e del(;btnDel.setBounds(180, 59, 77, 21;getContentPane(.add(btnDel;JButton btnUpdate = new JButton("更新"btnUpdate.addActionListener(new ActionListener( public void actionPerformed(ActionEvent e up
14、date(;btnUpdate.setBounds(280, 59, 77, 21;getContentPane(.add(btnUpdate;JButton btnFind = new JButton("查找"btnFind.addActionListener(new ActionListener( public void actionPerformed(ActionEvent e find(;btnFind.setBounds(380, 59, 77, 21;getContentPane(.add(btnFind;model = new DefaultTableMode
15、l(columns, 0;table = new JTable(model;table.addMouseListener(new MouseAdapter(public void mouseClicked(MouseEvent eint row = table.getSelectedRow(;department_idField.setText(String table.getValueAt(row, 0;department_nameField.setText(String table.getValueAt(row, 2;manager_idField.setText(String tabl
16、e.getValueAt(row, 3;location_idField.setText(String table.getValueAt(row, 4;tmp = getInput(;JScrollPane scrollPane = new JScrollPane(table;scrollPane.setBounds(12, 100, 571, 248;getContentPane(.add(scrollPane;setDefaultCloseOperation(EXIT_ON_CLOSE;setLocationRelativeTo(null;setLocation(350,200;setSi
17、ze(601, 380;setResizable(false;setVisible(true;private Student getInput( Student stu = new Student(;stu.department_id= department_idField.getText(;stu.department_name = department_nameField.getText(;stu.manager_id = manager_idField.getText(;stu.location_id = location_idField.getText(;return stu;priv
18、ate void add( data.add(getInput(;showTable(;private void del( for (int i = 0; i < data.size(; i+if (tmp.equals(data.get(i data.remove(i;break;showTable(;private void update( Student stu = getInput(;for (int i = 0; i < data.size(; i+if (tmp.equals(data.get(i data.remove(i;data.add(i, stu;break;
19、showTable(;private void find( removeRows(;Student stu = getInput(;for (int i = 0; i < data.size(; i+ Student tmp = (Student data.get(i;if (tmp.equals(stu model.addRow(tmp.toArray(;break;private void showTable( removeRows(;for (int i = 0; i < data.size(; i+Student stu = (Student data.get(i;mode
20、l.addRow(stu.toArray(;private void removeRows( while (model.getRowCount( > 0 model.removeRow(0;public static void main(String args new AppStudent(;class Studentimplements Serializable public String department_id;public String department_name;public String manager_id;public String location_id;publ
21、ic boolean equals(Object obj return equals(Student obj;public boolean equals(Student obj boolean isdepartment_id = true;if (obj.department_id != null && !"".equals(obj.department_id isdepartment_id = department_id.equals(obj.department_id;boolean isdepartment_name = true;if (obj.department_name != null && !"".equals(obj.department_name isdepartment_name = department_name.equals(obj.department_name;boolean ismanager_id = true;if (obj.manager_id != null && !"".equals(obj.manager_id isma
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 15MW農(nóng)光互補(bǔ)發(fā)電項(xiàng)目-接入系統(tǒng)設(shè)計(jì)報(bào)告
- 2024年二級(jí)造價(jià)師考試題庫(kù)4
- 第05課 網(wǎng)絡(luò)協(xié)議分層設(shè) 教學(xué)設(shè)計(jì) 2024-2025學(xué)年人教版(2024)初中信息技術(shù)七年級(jí)全一冊(cè)
- 商貿(mào)公司進(jìn)貨合同范例
- 鄭州餐飲連鎖加盟合同范例
- 寫字樓商鋪招租合同范例
- 電瓶定采購(gòu)合同范例
- 以店面入股合同范例
- 園林購(gòu)樹合同范例
- 土地合作建設(shè)合同范例
- GB/T 44978-2024智慧城市基礎(chǔ)設(shè)施連接城市和城市群的快速智慧交通
- 2025屆北京師范大學(xué)附中高三下學(xué)期聯(lián)考英語(yǔ)試題含解析
- 2024年企業(yè)年度營(yíng)銷策劃合同
- 中級(jí)計(jì)量經(jīng)濟(jì)學(xué)知到智慧樹章節(jié)測(cè)試課后答案2024年秋浙江工業(yè)大學(xué)
- 營(yíng)銷中心2024年規(guī)劃
- 【人教版一年級(jí)起點(diǎn)】三年級(jí)上冊(cè)英語(yǔ)英語(yǔ)知識(shí)點(diǎn)總結(jié)
- 樓門牌制作合同范例
- 嬰幼兒認(rèn)知發(fā)展與指導(dǎo)學(xué)習(xí)通超星期末考試答案章節(jié)答案2024年
- 消防設(shè)備施工方案
- DB43-T+3015-2014《校園食材配送服務(wù)規(guī)范》
- 公檢法聯(lián)席會(huì)議制度
評(píng)論
0/150
提交評(píng)論