第一范文网 - 专业文章范例文档资料分享平台

Java连接数据库增删改查(精)

来源:用户分享 时间:2025/9/14 7:19:39 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

Java连接sql2000数据库增删改查功能

学院:仲恺农业工程学院 姓名:陈伟团 专业:计算机科学与技术 班级:084班 1. 数据库连接 package edu;

import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class DBConnection {

public static Connection getConnection({ Connection conn = null;

String driver = \;

String url = \; String username = \; String password = \; try {

Class.forName(driver;

conn = DriverManager.getConnection(url,username,password; } catch (ClassNotFoundException e { e.printStackTrace(; } catch (SQLException e { e.printStackTrace(; }

return conn; }

2. 生成get set方法 package edu; public class Country { private String name; private String region; private String area;

private String population; private String gdp; public String getName( { return name; }

public void setName(String name { this.name = name; }

public String getRegion( { return region; }

public void setRegion(String region { this.region = region; }

public String getArea( { return area; }

public void setArea(String area { this.area = area; }

public String getPopulation( { return population; }

public void setPopulation(String population { this.population = population; }

public String getGdp( { return gdp; }

public void setGdp(String gdp {

this.gdp = gdp; } }

3实现方法 package edu;

import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.SwingUtilities;

public class CountryInfoGui implements ActionListener { private JFrame jFrame; private JPanel jContentPane; private JLabel lblName = null; private JTextField tfName = null; private JLabel lblRegion = null; private JComboBox cbRegion = null; private JLabel lblArea = null; private JTextField tfArea = null; private JLabel lblPopu = null; private JTextField tfPopu = null;

private JLabel lblGdp = null; private JTextField tfGDP = null; private JButton btnAdd = null; private JButton btnDel = null; private JButton btnModify = null; private JButton btnQuery = null; private JButton btnUpPage = null; private JButton btnDownPage = null; private JTable table = null; TableModel tm = null; JScrollPane jsp = null;

private JTextField getTfName( { if (tfName == null { tfName = new JTextField(;

tfName.setBounds(new Rectangle(89, 17, 173, 27; }

return tfName; }

private JComboBox getCbRegion( { if (cbRegion == null {

String[] str = { \请选择\, \亚洲\, \欧洲\, \非洲\, \北美洲\, \南美洲\, \大洋洲\, \南极洲\ };

cbRegion = new JComboBox(str;

cbRegion.setBounds(new Rectangle(360, 17, 229, 28; }

return cbRegion; }

private JTextField getTfArea( { if (tfArea == null { tfArea = new JTextField(;

搜索更多关于: Java连接数据库增删改查(精) 的文档
Java连接数据库增删改查(精).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c66xln3fhip02ra61x73m28mwx147wg01csx_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top