-
大小: 1.87MB文件類型: .zip金幣: 2下載: 0 次發布日期: 2023-10-26
- 語言: 數據庫
- 標簽:
資源簡介
完整的北大青鳥第二階段項目-超市賬單管理系統完整源代碼,已根據之前網友的評論和建議,在原有基礎上進行了相關的改進,現導入即可使用,無bug,歡迎大家學習交流!
注:sql腳本選擇最外層文件夾下的即可直接導入,比導入sql文件夾內的更為方便快捷。

代碼片段和文件信息
package?cn.pb.maket.dao;
import?java.sql.Connection;
import?java.sql.DriverManager;
import?java.sql.PreparedStatement;
import?java.sql.ResultSet;
import?java.sql.SQLException;
import?java.sql.Statement;
import?cn.pb.maket.util.ConfigManager;
/*
?*?數據庫操作基類
?*/
public?class?baseDao?{
protected?Connection?connection;
protected?PreparedStatement?pstmt;
protected?Statement?stmt;
protected?ResultSet?rs;
//1.?獲得數據庫連接
public?boolean?getConnection()?{
String?driver?=?ConfigManager.getInstance().getString(“driver_class“);
String?url?=?ConfigManager.getInstance().getString(“connection.url“);
String?username?=?ConfigManager.getInstance().getString(
“connection.username“);
String?psaaword?=?ConfigManager.getInstance().getString(
“connection.password“);
//?(1)加載驅動
try?{
Class.forName(driver);
//?2.使用DriverManager類的getConnection()方法獲得數據庫的鏈接
connection?=?DriverManager.getConnection(url?username?psaaword);
}?catch?(Exception?e)?{
e.printStackTrace();
return?false;
}
return?true;
}
//2.?增刪改
public?int?executeUptate(String?sql?object[]?params)?{
int?updateRows?=?0;
getConnection();
try?{
pstmt?=?connection.prepareStatement(sql);
for?(int?i?=?0;?i? pstmt.setobject(i?+?1?params[i]);
}
updateRows?=?pstmt.executeUpdate();
}?catch?(SQLException?e)?{
e.printStackTrace();
}
return?updateRows;
}
//?查詢
public?ResultSet?executeSQL(String?sql?object[]?params)?{
getConnection();
try?{
pstmt?=?connection.prepareStatement(sql);
for?(int?i?=?0;?i? pstmt.setobject(i?+?1?params[i]);
}
rs?=?pstmt.executeQuery();
}?catch?(SQLException?e)?{
e.printStackTrace();
}
return?rs;
}
//?關閉資源
public?boolean?closeResource()?{
if?(rs?!=?null)?{
try?{
rs.close();
}?catch?(SQLException?e)?{
e.printStackTrace();
return?false;
}
}
if?(stmt?!=?null)?{
try?{
stmt.close();
}?catch?(SQLException?e)?{
e.printStackTrace();
return?false;
}
}
if?(connection?!=?null)?{
try?{
connection.close();
}?catch?(SQLException?e)?{
e.printStackTrace();
return?false;
}
}
return?true;
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-11-25?14:35??超市管理---10-22\
?????目錄???????????0??2013-11-25?14:35??超市管理---10-22\maket\
?????文件?????????432??2013-09-20?14:36??超市管理---10-22\maket\.classpath
?????目錄???????????0??2013-11-25?14:36??超市管理---10-22\maket\.myeclipse\
?????文件?????????288??2013-10-24?09:32??超市管理---10-22\maket\.myme
?????文件????????1278??2013-10-21?10:11??超市管理---10-22\maket\.project
?????目錄???????????0??2013-11-25?14:35??超市管理---10-22\maket\.settings\
?????文件?????????330??2013-09-20?14:35??超市管理---10-22\maket\.settings\org.eclipse.jdt.core.prefs
?????目錄???????????0??2013-11-25?14:35??超市管理---10-22\maket\WebRoot\
?????目錄???????????0??2013-09-20?17:55??超市管理---10-22\maket\WebRoot\me
?????文件??????????36??2013-09-20?14:35??超市管理---10-22\maket\WebRoot\me
?????目錄???????????0??2013-11-25?14:35??超市管理---10-22\maket\WebRoot\WEB-INF\
?????目錄???????????0??2013-11-25?14:35??超市管理---10-22\maket\WebRoot\WEB-INF\classes\
?????目錄???????????0??2013-10-24?09:32??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\
?????目錄???????????0??2013-10-24?09:32??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\
?????目錄???????????0??2013-10-24?09:32??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\maket\
?????目錄???????????0??2013-11-25?14:35??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\maket\dao\
?????文件????????2629??2013-10-24?09:32??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\maket\dao\ba
?????文件?????????511??2013-10-24?09:32??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\maket\dao\BillDao.class
?????文件?????????661??2013-10-24?09:32??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\maket\dao\ProviderDao.class
?????文件?????????550??2013-10-24?09:32??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\maket\dao\UsersDao.class
?????目錄???????????0??2013-11-25?14:35??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\maket\dao\impl\
?????文件????????6405??2013-10-24?10:32??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\maket\dao\impl\BillDaoImpl.class
?????文件????????6184??2013-10-24?09:32??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\maket\dao\impl\ProviderDaoImpl.class
?????文件????????5545??2013-10-24?09:32??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\maket\dao\impl\UsersDaoImpl.class
?????目錄???????????0??2013-11-25?14:35??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\maket\entity\
?????文件????????2373??2013-10-24?10:32??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\maket\entity\Bill.class
?????文件????????2410??2013-10-24?09:32??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\maket\entity\Provider.class
?????文件????????1919??2013-10-24?09:32??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\maket\entity\Users.class
?????目錄???????????0??2013-11-25?14:35??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\maket\servlet\
?????文件????????2571??2013-10-24?09:32??超市管理---10-22\maket\WebRoot\WEB-INF\classes\cn\pb\maket\servlet\AddBillServlet.class
............此處省略128個文件信息
評論
共有 條評論