![JAVAswing界面實現(xiàn)數(shù)據(jù)庫增刪改查_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/12/0fe0ee6d-a5a9-4d6e-afe2-6f5406d127f3/0fe0ee6d-a5a9-4d6e-afe2-6f5406d127f31.gif)
![JAVAswing界面實現(xiàn)數(shù)據(jù)庫增刪改查_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/12/0fe0ee6d-a5a9-4d6e-afe2-6f5406d127f3/0fe0ee6d-a5a9-4d6e-afe2-6f5406d127f32.gif)
![JAVAswing界面實現(xiàn)數(shù)據(jù)庫增刪改查_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/12/0fe0ee6d-a5a9-4d6e-afe2-6f5406d127f3/0fe0ee6d-a5a9-4d6e-afe2-6f5406d127f33.gif)
![JAVAswing界面實現(xiàn)數(shù)據(jù)庫增刪改查_第4頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/12/0fe0ee6d-a5a9-4d6e-afe2-6f5406d127f3/0fe0ee6d-a5a9-4d6e-afe2-6f5406d127f34.gif)
![JAVAswing界面實現(xiàn)數(shù)據(jù)庫增刪改查_第5頁](http://file3.renrendoc.com/fileroot_temp3/2022-1/12/0fe0ee6d-a5a9-4d6e-afe2-6f5406d127f3/0fe0ee6d-a5a9-4d6e-afe2-6f5406d127f35.gif)
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、數(shù)據(jù)庫程序設計大作業(yè)班級:2012級軟件外包服務一班學號:201215140117姓名: 。時間:2013-6-19 1功能描述1.1 功能簡介用swing做出圖形化界面形式,實現(xiàn)數(shù)據(jù)庫的增刪改查把員工表跟部門表連接起來,實現(xiàn)數(shù)據(jù)的增加,刪除,修改,查找。1.2 實現(xiàn)步驟(1)安裝好虛擬機,并在其下確認oracle已安裝成功(可以在dos下輸入相關命令來檢查是否安裝成功)。(2)在網(wǎng)絡中心修改pc機上的VMware Network Adapter的IP、子網(wǎng)頁碼(默認)、網(wǎng)關。(3)修改虛擬機的IP、網(wǎng)掩碼(默認)、網(wǎng)關,確保PC機上的網(wǎng)關和虛擬機的IP一致。(在控制面板>網(wǎng)絡和共享中心
2、>本地連接3>屬性中,修改IP、網(wǎng)掩碼)(4)在PC機的dos命令控制臺ping虛擬機的IP,確保正常,能ping通(即將虛擬機內外ping通)。(5)配置好虛擬機下的oracle的數(shù)據(jù)庫和監(jiān)聽。(6)在eclipse中編寫相關代碼,并用jtable實現(xiàn)圖形化界面,用以實現(xiàn)與數(shù)據(jù)庫的連接和操作數(shù)據(jù)庫等功能。(7)在eclipse中導入數(shù)據(jù)庫的驅動。(8)運行eclipse,查看運行結果。2. 核心代碼2.11. 數(shù)據(jù)庫連接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實現(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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 文山2024年云南文山市緊密型醫(yī)療衛(wèi)生共同體總醫(yī)院招聘54人筆試歷年參考題庫附帶答案詳解
- 2025年中國減脂儀市場調查研究報告
- 2025至2031年中國高效低噪音節(jié)能離心通風機行業(yè)投資前景及策略咨詢研究報告
- 2025年紅瑪瑙情侶吊墜項目可行性研究報告
- 2025至2031年中國短袖迷彩服行業(yè)投資前景及策略咨詢研究報告
- 2025年洗衣車項目可行性研究報告
- 2025年有色打字機項目可行性研究報告
- 2025至2031年中國小麥胚芽油軟膠囊行業(yè)投資前景及策略咨詢研究報告
- 2025年實木復合拼花門項目可行性研究報告
- 2025年雙色移印機項目可行性研究報告
- 化學選修4《化學反應原理》(人教版)全部完整PP課件
- 《煤礦安全規(guī)程》專家解讀(詳細版)
- 招聘面試流程sop
- 建筑公司工程財務報銷制度(精選7篇)
- 工程設計方案定案表
- 最新2022年減肥食品市場現(xiàn)狀與發(fā)展趨勢預測
- 第一章-天氣圖基本分析方法課件
- 暖氣管道安裝施工計劃
- 體育實習周記20篇
- 初二物理彈力知識要點及練習
- 復合材料成型工藝及特點
評論
0/150
提交評論