资源简介

1.java 课程设计《超市收银系统》连接数据库 2. 包含课程设计报告 3.JDBC桥包 JDT驱动 4.连接了sql sever 数据库 5.包含了数据库备份文档

资源截图

代码片段和文件信息

package com.supermk;

import javax.swing.*;


import java.awt.*;
import java.awt.event.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;

public class Add extends JDialog implements ActionListener
{

public static final String Statement = null;

JPanel p = new JPanel();
JLabel name= new JLabel(“会员卡号:“);
JTextField t1 = new JTextField();
JLabel department = new JLabel(“姓名:“);
JTextField t2 = new JTextField();
JLabel phone =  new JLabel(“金额:“);
JTextField t3 = new JTextField();
JButton b1=new JButton(“提交“);
JButton b2 = new JButton(“退出“);


public Add(main cString titleboolean modal)
{
super(ctitlemodal);
this.setLayout(null);//设置窗口布局管理器  
this.setSize(300250);
name.setBounds(50606020);
this.add(name);
t1.setBounds(120608020);
this.add(t1);
department.setBounds(501006020);
this.add(department);
t2.setBounds(1201008020);
this.add(t2);
phone.setBounds(501406220);
this.add(phone);
t3.setBounds(1201408020);
this.add(t3);

b1.setBounds(801806020);
this.add(b1);
b2.setBounds(1601806020);
this.add(b2);
b1.addActionListener(this);//给登陆按钮添加监听器 
b2.addActionListener(this);
this.setVisible(true);//设置窗口的可见性 
this.setSize(300250);//设置窗口的大小      
}


 
public void actionPerformed(ActionEvent e)
{
String driverName=“com.microsoft.sqlserver.jdbc.SQLServerDriver“;// 定义数据库驱动程序
String dbURL=“jdbc:sqlserver://localhost:1433;DatabaseName=Supermk“;// 定义数据库的连接地址
String userName=“sa“;
String userPwd=“941118“;
try
{
Class.forName(driverName);//加载数据库驱动
}catch(java.lang.ClassNotFoundException eee)
{}


if(e.getSource()==b1)//处理登陆事件           
{
String name=t1.getText();
String department=t2.getText();
String phone = t3.getText();
if(t1.getText().equals(““) || t2.getText().equals(““) || t3.getText().equals(““))
{
JOptionPane.showMessageDialog(null“数据不完善,存在未填!“);
t1.setText(null);
t2.setText(null);
t3.setText(null);
}
else
{
try{
Connection con=DriverManager.getConnection(dbURLuserNameuserPwd);
String sql=“insert into vip(vipnuvipnayuer) values(???)“;
PreparedStatement stmt=con.prepareStatement(sql);//使用PreparedStatement接口来实现,是Statement子接口,实例化一个对象

stmt.setString(1name);//第一个问号的内容
stmt.setString(2department);//第二个
stmt.setString(3phone);//第三个

stmt.execute();//执行数据库更新操作

stmt.close();//关闭操作
con.close();//关闭数据库
}catch(Exception e1){
System.out.println(e1.getMessage());
JOptionPane.showMessageDialog(this “插入出现问题请重新填写数据“);
t1.setText(null);
t2.setText(null);
t3.setText(null);
return;
}
JOptionPane.showMessageDialog(this “添加成功“);
dispose();      
}                         
}    

if(e.getSource()==b2)
{
dispose();
}
}


}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     563117  2012-02-29 17:11  chaoshishouyin\sqljdbc.jar

     文件     584207  2012-02-29 17:11  chaoshishouyin\sqljdbc4.jar

     文件        440  2016-12-22 11:07  chaoshishouyin\supermk\.classpath

     文件        383  2016-12-22 10:20  chaoshishouyin\supermk\.project

     文件        116  2016-12-22 18:16  chaoshishouyin\supermk\.settings\org.eclipse.core.resources.prefs

     文件        598  2016-12-22 10:20  chaoshishouyin\supermk\.settings\org.eclipse.jdt.core.prefs

     文件       4066  2016-12-22 18:25  chaoshishouyin\supermk\bin\com\supermk\Add.class

     文件       5805  2016-12-22 18:45  chaoshishouyin\supermk\bin\com\supermk\main.class

     文件     317816  2013-06-08 12:27  chaoshishouyin\supermk\lib\jtds-1.3.1.jar

     文件       3307  2016-12-22 18:25  chaoshishouyin\supermk\src\com\supermk\Add.java

     文件       5503  2016-12-22 18:45  chaoshishouyin\supermk\src\com\supermk\main.java

     文件    5242880  2016-12-22 18:53  chaoshishouyin\Supermk.mdf

     文件    1048576  2016-12-22 18:53  chaoshishouyin\Supermk_log.ldf

     文件     232538  2016-12-22 19:49  chaoshishouyin\报告.docx

     目录          0  2016-12-22 18:54  chaoshishouyin\supermk\bin\com\supermk

     目录          0  2016-12-22 18:54  chaoshishouyin\supermk\src\com\supermk

     目录          0  2016-12-22 18:54  chaoshishouyin\supermk\bin\com

     目录          0  2016-12-22 18:54  chaoshishouyin\supermk\src\com

     目录          0  2016-12-22 18:54  chaoshishouyin\supermk\.settings

     目录          0  2016-12-22 18:54  chaoshishouyin\supermk\bin

     目录          0  2016-12-22 18:54  chaoshishouyin\supermk\lib

     目录          0  2016-12-22 18:54  chaoshishouyin\supermk\src

     目录          0  2016-12-22 18:54  chaoshishouyin\supermk

     目录          0  2016-12-22 19:54  chaoshishouyin

----------- ---------  ---------- -----  ----

              8009352                    24


评论

共有 条评论