ImageVerifierCode 换一换
格式:DOCX , 页数:12 ,大小:47.50KB ,
资源ID:20872409      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/20872409.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(完整word版JAVAswing界面实现数据库增删改查精文档格式.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

完整word版JAVAswing界面实现数据库增删改查精文档格式.docx

1、(8)运行eclipse,查看运行结果。2. 核心代码2.11. 数据库连接package org.lxh.info.dbc;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;public class DatabaseConnection public static void main(String args Connection conn = null;Statemen

2、t stmt = null;ResultSet rs = null;try Class.forName(oracle.jdbc.driver.OracleDriver;String url = jdbc:oracle:thin:192.168.0.128:1521/WFJconn = DriverManager.getConnection(url, hr, stmt = conn.createStatement(;String sql = select * from departmentsrs = stmt.executeQuery(sql;while (rs.next( System.out

3、.print(rs.getInt(department_idSystem.out.print(tSystem.out.print(rs.getString(department_namemanager_idlocation_idSystem.out.println(; catch (ClassNotFoundException e e.printStackTrace(; catch (SQLException e finally if (rs != null rs.close(;if (stmt !stmt.close(;if (conn !conn.close(;/ TODO Auto-ge

4、nerated catch block2. 生成get set方法package edu;public class Country private String department_id;private String department_name;private String area;private String population;public String getdepartment_id( return department_id;public void setdepartment_id(String department_name this.name = department_

5、id;public String getdepartment_name( return department_name;public void setdepartment_name(String department_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

6、( return location_id;public void setlocation_id(String location_idn this.location_id = location_id;3实现方法package tuxinghua;import java.awt.Color;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.Serializable;import java.util.ArrayList;import java.util.List;import j

7、avax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.JTextField;import javax.swing.table.DefaultTableModel;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;public class AppStudent extends

8、 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 = ;private List data;private Student tmp; public AppStudent( data =

9、new ArrayList(;getContentPane(.setLayout(null;JLabel lblemployee = new JLabel(lblemployee.setBounds(12, 10, 220, 13;getContentPane(.add(lblemployee;department_idField = new JTextField(;department_idField.setBounds(100, 7, 96, 19;getContentPane(.add(department_idField;department_idField.setColumns(10

10、;JLabel lblAge = new JLabel(lblAge.setBounds(252, 10, 220, 13;getContentPane(.add(lblAge;department_nameField = new JTextField(;department_nameField.setBounds(365, 7, 96, 19;getContentPane(.add(department_nameField;department_nameField.setColumns(10;JLabel lblStuno = new JLabel(lblStuno.setBounds(12

11、, 36, 220, 13;getContentPane(.add(lblStuno;manager_idField = new JTextField(;manager_idField.setColumns(10;manager_idField.setBounds(100, 33, 96, 19;getContentPane(.add(manager_idField;JLabel lblClass = new JLabel(lblClass.setBounds(252, 36, 220, 13;getContentPane(.add(lblClass;location_idField = ne

12、w JTextField(;location_idField.setColumns(10;location_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(

13、btnAdd;JButton btnDel = new JButton(删除btnDel.addActionListener(new ActionListener( del(;btnDel.setBounds(180, 59, 77, 21;getContentPane(.add(btnDel;JButton btnUpdate = new JButton(更新btnUpdate.addActionListener(new ActionListener( update(;btnUpdate.setBounds(280, 59, 77, 21;getContentPane(.add(btnUpd

14、ate;JButton btnFind = new JButton(查找btnFind.addActionListener(new ActionListener( find(;btnFind.setBounds(380, 59, 77, 21;getContentPane(.add(btnFind;model = new DefaultTableModel(columns, 0;table = new JTable(model;table.addMouseListener(new MouseAdapter(public void mouseClicked(MouseEvent eint row

15、 = table.getSelectedRow(;department_idField.setText(String table.getValueAt(row, 0;department_nameField.setText(String table.getValueAt(row, 2;manager_idField.setText(String table.getValueAt(row, 3;location_idField.setText(String table.getValueAt(row, 4;tmp = getInput(;JScrollPane scrollPane = new J

16、ScrollPane(table;scrollPane.setBounds(12, 100, 571, 248;getContentPane(.add(scrollPane;setDefaultCloseOperation(EXIT_ON_CLOSE;setLocationRelativeTo(null;setLocation(350,200;setSize(601, 380;setResizable(false;setVisible(true;private Student getInput( Student stu = new Student(;stu.department_id= dep

17、artment_idField.getText(;stu.department_name = department_nameField.getText(;stu.manager_id = manager_idField.getText(;stu.location_id = location_idField.getText(;return stu;private void add( data.add(getInput(;showTable(;private void del( for (int i = 0; i 0 model.removeRow(0;new AppStudent(;class

18、Studentimplements Serializable public String department_id;public String department_name;public String manager_id;public String location_id;public boolean equals(Object obj return equals(Student obj;public boolean equals(Student obj boolean isdepartment_id = true;if (obj.department_id != null & !.eq

19、uals(obj.department_id isdepartment_id = department_id.equals(obj.department_id;boolean isdepartment_name = true;if (obj.department_name !.equals(obj.department_name isdepartment_name = department_name.equals(obj.department_name;boolean ismanager_id = true;if (obj.manager_id !.equals(obj.manager_id

20、ismanager_id = manager_id.equals(obj.manager_id;boolean islocation_id = true;if (obj.location_id !.equals(obj.location_id islocation_id = location_id.equals(obj.location_id;return isdepartment_id& isdepartment_name & ismanager_id & islocation_id;public String toArray( return new String department_id

21、, department_name, manager_id, location_idpublic void setVisible(boolean b / TODO Auto-generated method stub3. 实训总结通过这次实训我发现了自己许多的缺点和不足,我一定会好好找出不足,尽最大可能去改正,不断进步发展。对于本次实训,我表示很遗憾,未能达到预期的效果,归根到底还是关于java的知识没学好。我认为基础知识是很重要的,图形化界面要在eclipse中实现必须要熟悉jframe的功能,只有熟知jframe的所有功能才能对图形化界面做出来,但是我对之一部分的了解是少之又少,不足以通过jframe来实现图形化界面,并且在里面连接数据库,实现oracle中hr用户中department 和employees这两张表的增删改查。

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1