資源簡介
這是數據庫課設做的,用的B/S系統,文檔和sql文件都有
代碼片段和文件信息
package?trouble.dao;
import?java.sql.SQLException;
import?java.util.ArrayList;
import?java.util.List;
import?org.apache.commons.dbutils.QueryRunner;
import?org.apache.commons.dbutils.handlers.BeanHandler;
import?org.apache.commons.dbutils.handlers.BeanListHandler;
import?org.apache.commons.dbutils.handlers.ScalarHandler;
import?trouble.domain.Enterprise;
import?trouble.utils.C3P0Util;
public?class?EnterpriseDao?{
public?int?count(String?category)?throws?SQLException?{
QueryRunner?qr?=?new?QueryRunner(C3P0Util.getDataSource());
String?sql?=?“select?count(*)?from?enterprise“;
//?如果category不是空,就把條件加上
if?(!““.equals(category))?{
sql?+=?“?where?nature=‘“?+?category?+?“‘“;
}
long?l?=?(Long)?qr.query(sql?new?ScalarHandler(1));
return?(int)?l;
}
public?List?findEnterprises(int?currentPage?int?pageSize?String?category)?throws?SQLException?{
QueryRunner?qr?=?new?QueryRunner(C3P0Util.getDataSource());
String?sql?=?“select?*?from?enterprise?where?1=1“;
List?list?=?new?ArrayList();
if?(!““.equals(category))?{
sql?+=?“?and?nature=?“;
list.add(category);
}
sql?+=?“?limit???“;
list.add((currentPage?-?1)?*?pageSize);
list.add(pageSize);
return?qr.query(sql?new?BeanListHandler(Enterprise.class)?list.toArray());
}
public?Enterprise?findEnterpriseById(String?id)?throws?SQLException?{
QueryRunner?qr?=?new?QueryRunner(C3P0Util.getDataSource());
return?qr.query(“select?*?from?enterprise?where?id=?“?new?BeanHandler(Enterprise.class)?id);
}
public?List?findEnterprise()?throws?SQLException?{
QueryRunner?qr?=?new?QueryRunner(C3P0Util.getDataSource());
return?qr.query(“select?*?from?enterprise“?new?BeanListHandler(Enterprise.class));
}
public?List?findEnterpriseByManyCondition(String?id?String?category?String?name)?throws?SQLException?{
QueryRunner?qr?=?new?QueryRunner(C3P0Util.getDataSource());
String?sql?=?“select?*?from?enterprise?where?1=1“;
if?(!““.equals(id.trim()))
sql?+=?“?and?id=‘“?+?id?+?“‘“;
if?(!““.equals(category.trim()))
sql?+=?“?and?nature=‘“?+?category?+?“‘“;
if?(!““.equals(name.trim()))
sql?+=?“?and?name=‘“?+?name?+?“‘“;
//?System.out.println(sql);
return?qr.query(sql?new?BeanListHandler(Enterprise.class));
}
public?void?addEnterprise(String?name?String?corporate?String?telephone?String?category?String?description
String?img_url)?throws?SQLException?{
QueryRunner?qr?=?new?QueryRunner(C3P0Util.getDataSource());
String?sql?=?“INSERT?INTO?enterprise(NAMEnaturecorporateintroducetelephoneimg_url)?VALUES(??????)“;
qr.update(sqlnamecategorycorporatedescriptiontelephoneimg_url);
}
public?void?updateEnterprise(String?id?String?name?String?corporate?String?telephone?String?category
String?description)?throws?SQLException?{
QueryRunner?qr?=?new?QueryRunner(
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-07-04?10:25??laborInformation\
?????文件?????????842??2018-07-04?09:50??laborInformation\.classpath
?????目錄???????????0??2018-07-04?10:28??laborInformation\.git\
?????文件??????????13??2018-07-04?10:26??laborInformation\.git\COMMIT_EDITMSG
?????文件?????????313??2018-07-04?10:28??laborInformation\.git\config
?????文件??????????73??2018-07-04?09:34??laborInformation\.git\desc
?????文件?????????108??2018-07-04?09:50??laborInformation\.git\FETCH_HEAD
?????文件??????????23??2018-07-04?09:50??laborInformation\.git\HEAD
?????目錄???????????0??2018-07-04?09:34??laborInformation\.git\hooks\
?????文件?????????478??2018-07-04?09:34??laborInformation\.git\hooks\applypatch-msg.sample
?????文件?????????896??2018-07-04?09:34??laborInformation\.git\hooks\commit-msg.sample
?????文件????????3327??2018-07-04?09:34??laborInformation\.git\hooks\fsmonitor-watchman.sample
?????文件?????????189??2018-07-04?09:34??laborInformation\.git\hooks\post-update.sample
?????文件?????????424??2018-07-04?09:34??laborInformation\.git\hooks\pre-applypatch.sample
?????文件????????1638??2018-07-04?09:34??laborInformation\.git\hooks\pre-commit.sample
?????文件????????1348??2018-07-04?09:34??laborInformation\.git\hooks\pre-push.sample
?????文件????????4898??2018-07-04?09:34??laborInformation\.git\hooks\pre-reba
?????文件?????????544??2018-07-04?09:34??laborInformation\.git\hooks\pre-receive.sample
?????文件????????1492??2018-07-04?09:34??laborInformation\.git\hooks\prepare-commit-msg.sample
?????文件????????3610??2018-07-04?09:34??laborInformation\.git\hooks\update.sample
?????文件???????37585??2018-07-04?10:26??laborInformation\.git\index
?????目錄???????????0??2018-07-04?09:34??laborInformation\.git\info\
?????文件?????????240??2018-07-04?09:34??laborInformation\.git\info\exclude
?????目錄???????????0??2018-07-04?09:36??laborInformation\.git\logs\
?????文件?????????861??2018-07-04?10:26??laborInformation\.git\logs\HEAD
?????目錄???????????0??2018-07-04?09:43??laborInformation\.git\logs\refs\
?????目錄???????????0??2018-07-04?09:36??laborInformation\.git\logs\refs\heads\
?????文件?????????517??2018-07-04?10:26??laborInformation\.git\logs\refs\heads\master
?????目錄???????????0??2018-07-04?09:45??laborInformation\.git\logs\refs\remotes\
?????目錄???????????0??2018-07-04?09:50??laborInformation\.git\logs\refs\remotes\origin\
?????文件?????????456??2018-07-04?10:28??laborInformation\.git\logs\refs\remotes\origin\master
............此處省略1003個文件信息
- 上一篇:ssm開發的論壇項目
- 下一篇:高校成績管理系統數據庫設計與實現含源碼和報告
評論
共有 條評論