基于java+mysql的Swing+Java+MySQL商品管理系统
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
商品信息管理,简单的增删改查
技术框架
Java Swing MySQL
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
import javax.swing.JButton;
public class GoodsXG extends JFrame {
private JTextField id,name,num,price;
private JButton button;
private JButton button_1;
int goodsid;
public GoodsXG(Goods goods) {
super("商品管理系统");
this.setBounds(0, 0, 400, 450);
this.setLocationRelativeTo(null);//让窗口在屏幕中间显示
getContentPane().add(id);
id.setColumns(10);
JLabel label_1 = new JLabel("商品名称");
label_1.setBounds(85, 139, 87, 22);
getContentPane().add(label_1);
name = new JTextField();
name.setColumns(10);
name.setBounds(147, 140, 142, 21);
getContentPane().add(name);
JLabel label_2 = new JLabel("数量:");
label_2.setBounds(85, 193, 87, 22);
getContentPane().add(label_2);
num = new JTextField();
num.setColumns(10);
num.setBounds(147, 194, 142, 21);
getContentPane().add(num);
JLabel label_3 = new JLabel("单价:");
label_3.setBounds(85, 241, 87, 22);
getContentPane().add(label_3);
price = new JTextField();
//增、删、改、查
public static int updataInfo(String sql) {
System.out.println(sql);
//获取连接
Connection connection = getConnection();
try {
PreparedStatement psd = connection.prepareStatement(sql);
return psd.executeUpdate();
} catch (SQLException e) {
JOptionPane.showMessageDialog(null, "执行语句出错\n" + e.toString());
e.printStackTrace();
}
return 0;
}
//关闭连接
public static void colse(ResultSet rs, Statement stmt, Connection conn) throws Exception {
try {
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.cancel();
}
if (conn != null) {
Select select = new Select();
private JTextField textField;
Object[] header= {
"商品编号","商品名称","数量"