资源简介
这是一个小型的系统,界面美观,拿来按照里面的操作导入数据库,就能使用,简单方便,供初学者使用,对老司机也有参考价值

代码片段和文件信息
/**
* 对数据库操作的类
* 对数据库的操作,就是crud
* 调用存储过程
*/
package com.db;
import java.sql.*;
public class SqlHelper {
// 定义需要的对象
Connection ct = null;
PreparedStatement ps = null;
ResultSet rs = null;
// 连接数据库需要的字符串
String driver = “com.microsoft.jdbc.sqlserver.SQLServerDriver“;
String url = “jdbc:sqlserver://127.0.0.1:1433;databaseName=myshop“;
String user = “sa“;
String passwd = “418218“;
// 构造函数,初始化ct
public SqlHelper() {
try {
// 加载驱动
Class.forName(driver);
// 得到连接
ct = DriverManager.getConnection(url user passwd);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println(“驱动没有加载成功原因是没有导入驱动!请检查“);
} catch (NullPointerException e) {
// TODO Auto-generated catch bloc
e.printStackTrace();
System.out.println(“数据库服务没有开启,请打开数据库服务,再重试“);
} catch (SQLException e) {
// TODO Auto-generated catch bloc
e.printStackTrace();
}
}
// 关闭资源的方法
public void close() {
try {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
if (ct != null) {
ct.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
// []paras,通过?赋值方式可以防止漏洞注入方式,保证安全性
public ResultSet query(String sql String[] paras) {
try {
ps = ct.prepareStatement(sql);
// 对sql的参数赋值
for (int i = 0; i < paras.length; i++) {
ps.setString(i + 1 paras[i]);
}
// 执行查询
rs = ps.executeQuery();
} catch (Exception e) {
e.printStackTrace();
}
// 返回结果集
return rs;
}
// 增删改方法
public boolean update(String sql String[] paras) {
boolean b = true;
try {
ps = ct.prepareStatement(sql);
// 循环的对paras赋值,?赋值法
for (int i = 0; i < paras.length; i++) {
ps.setString(i+1 paras[i]);
}
// 执行操作
ps.execute();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
System.out.println(“SqlHelper中增删改中出错啦,请检查!“);
b = false;
}
return b;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-06-08 16:36 小型店铺管理系统\
目录 0 2017-06-08 16:36 小型店铺管理系统\MyShop\
文件 736 2013-07-29 20:52 小型店铺管理系统\MyShop\.classpath
文件 382 2013-06-23 15:45 小型店铺管理系统\MyShop\.project
目录 0 2017-06-08 16:36 小型店铺管理系统\MyShop\.settings\
文件 629 2013-06-23 15:45 小型店铺管理系统\MyShop\.settings\org.eclipse.jdt.core.prefs
目录 0 2017-06-08 16:36 小型店铺管理系统\MyShop\bin\
目录 0 2017-06-08 16:36 小型店铺管理系统\MyShop\bin\com\
目录 0 2017-06-08 16:36 小型店铺管理系统\MyShop\bin\com\db\
文件 2973 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\db\SqlHelper.class
目录 0 2017-06-08 16:36 小型店铺管理系统\MyShop\bin\com\model\
文件 3029 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\model\EmpModel.class
文件 2267 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\model\LoginModel.class
文件 2317 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\model\LookStcokModel.class
文件 3169 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\model\MemberModel.class
文件 3699 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\model\ProductModel.class
文件 2405 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\model\RecordModel.class
文件 2252 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\model\ReportModel.class
文件 3083 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\model\SellModel.class
文件 3375 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\model\ShowKuanModel.class
目录 0 2017-06-08 16:36 小型店铺管理系统\MyShop\bin\com\mytools\
文件 973 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\mytools\ImagePanel.class
文件 712 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\mytools\MyFont.class
文件 669 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\mytools\MySelfTabbedPane$ColorSet.class
文件 2024 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\mytools\MySelfTabbedPane$RollOverListener.class
文件 6776 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\mytools\MySelfTabbedPane.class
文件 6430 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\mytools\Tools.class
目录 0 2017-06-08 16:36 小型店铺管理系统\MyShop\bin\com\view\
文件 851 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\view\Add_Product_View$1.class
文件 975 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\view\Add_Product_View$2.class
文件 1094 2013-08-01 00:22 小型店铺管理系统\MyShop\bin\com\view\Add_Product_View$3.class
............此处省略122个文件信息
相关资源
- sqlserver学习ppt 全套共18个
- 门禁系统论文及数据库sqlserver2005数据
- 企业人事管理系统【SQLServer数据库+课
- 数据字典导出工具 导出SqlServer数据库
- 安装SQLServer 2008 R2安装详细图文教程
- SQLServer2008R2简体中文版(64位)
- SQL Server 2000 绿色版
- sql server 2012 R2企业版安装光盘ISO
- 6.SparkSQL下--Spark实战应用.pdf
- SqlServer+ServHA Cluster双机热备配置实战
- 易语言SQLserver数据库操作例程源码
- SqlServer日志恢复数据工具
- 电子图书管理系统
- 数据库系统概念第六版大学模式数据
- sqlserver图片导出工具
- Xposed提取微信数据库密码(微信6.6.
- 深入解析SQL SERVER 2008
- netbeans个人通讯录
- SQL Server数据挖掘与商业智能基础及案
- Microsoft SQL Server 2008技术内幕T-SQL语言
- 旅游业信息化服务平台
- SSH+Spring Security+MySQL
- SQL.Server.2005.技术内幕四部中文版 PD
- 2019最新银行卡bin表单、包含excel表,
- springmvc+spring+mybatis+mysql数据库整合读
- Delphi实现excel和SQLserver数据的导入导出
- MSSQL数据库查看器
- 用户同一时段不能重复登录类似QQMy
- SSM+mysql购书商城2018届毕设
- 网上订票系统
评论
共有 条评论