




版權(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)聽(tīng)。(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 第四章 6 光的偏振 激光-2025版高二物理選擇性必修一
- 采購(gòu)一周述職報(bào)告
- 特許金融分析師考試研究報(bào)告題試題及答案
- 水變干凈流程圖
- 2025屆陜西省菁師聯(lián)盟高三下學(xué)期3月聯(lián)考(一模)歷史試題(解析版)
- 政教處工作總結(jié)3
- 金融市場(chǎng)趨勢(shì)分析與試題及答案
- CFA各級(jí)別考試內(nèi)容對(duì)比試題及答案
- CFA考試深度備考策略與試題及答案
- 通過(guò)特許金融分析師考試的心理建設(shè)與試題及答案
- 2022年中國(guó)通用技術(shù)集團(tuán)控股有限責(zé)任公司招聘筆試題庫(kù)及答案解析
- 小學(xué) 三年級(jí) 心理健康《最好的老師-興趣的作用》教學(xué)設(shè)計(jì)
- 間歇經(jīng)口管飼法 課件
- 導(dǎo)電膠rohs2.078中文深圳市華測(cè)檢測(cè)技術(shù)股份市浦東新區(qū)新金橋路1996號(hào)
- 9 短詩(shī)三首 生字筆順課件(共10張PPT)
- 無(wú)線射頻識(shí)別技術(shù)外文翻譯參考文獻(xiàn)
- 電力負(fù)荷曲線與用電負(fù)荷預(yù)測(cè)課件
- 鋼支撐、圍檁專項(xiàng)施工方案
- 【2021部編版語(yǔ)文】-四年級(jí)下冊(cè)第六單元教材解讀--PPT課件
- 壓力管道安裝許可證換證自評(píng)報(bào)告
- 起重機(jī)械定期檢驗(yàn)規(guī)則概述
評(píng)論
0/150
提交評(píng)論