資源簡介
系統采用servlet + jsp + mvc設計模式,數據庫采用mssqlserver 2008 r2,詳情參考網址http://blog.csdn.net/u013082133/article/details/42033383

代碼片段和文件信息
package?com.m2sa.dao;
import?java.sql.SQLException;
import?java.util.List;
import?java.util.Map;
import?org.apache.commons.dbutils.QueryRunner;
import?org.apache.commons.dbutils.handlers.ArrayHandler;
import?org.apache.commons.dbutils.handlers.BeanHandler;
import?org.apache.commons.dbutils.handlers.BeanListHandler;
import?org.apache.commons.dbutils.handlers.MapHandler;
import?org.apache.commons.dbutils.handlers.MapListHandler;
import?com.m2sa.dao.domain.Course;
import?com.m2sa.dao.domain.PageCourse;
import?com.m2sa.utils.jdbcUtils;
public?class?CourseDao?{
/**獲取所有課程的信息
?*?@return?
?*?@throws?SQLException?*/
//@Deprecated過時
public?List?getAllcourseInfo()?throws?SQLException{
String?sql?=?“select?*?from?course“;
QueryRunner?qr?=?new?QueryRunner(jdbcUtils.getDataSource()?true);
List?list?=?qr.query(sql?new?BeanListHandler(Course.class));
return?list;
}
/**得到課程信息信息的總記錄數
?*?@throws?SQLException?*/
public?int?getTotalCourseInfo()?throws?SQLException{
String?sql?=?“select?count(*)?from?course“;
QueryRunner?qr?=?new?QueryRunner(jdbcUtils.getDataSource()?true);
object[]?arr?=?qr.query(sql?new?ArrayHandler());
return?(int)?arr[0];
}
/**分頁獲取學生的信息
?*?@throws?SQLException?*/
public?List?getPageCourseInfo(int?PageIndex?int?PageSize)?throws?SQLException{
String?sql?=?“select?top?“+PageSize+“?*?“
+“from?course?“
+“where?courseid?not?in?“
+“(select?top?“+PageSize?*?(PageIndex-1)?+“?courseid?from?course?order?by?courseid?asc)?“
+“order?by?courseid?asc“;
QueryRunner?qr?=?new?QueryRunner(jdbcUtils.getDataSource()?true);
return?qr.query(sql?new?BeanListHandler(Course.class));
}
/**?添加課程信息
?*?@throws?SQLException?*/
public?int?add_courseInfo(Course?course)?throws?SQLException{
String?sql?=?“insert?into?course?values(??????)“;
QueryRunner?qr?=?new?QueryRunner(jdbcUtils.getDataSource()?true);
object[]?params?=?{course.getCourseid()course.getCname()course.getPeriod()course.getDepartment()course.getTeacherid()course.getTeachername()};
int?state?=?qr.update(sql?params);
return?state;
}
/**檢查課程是否存在
?*?@throws?SQLException?*/
public?boolean?isAppear(String?courseId)?throws?SQLException?{
String?sql?=?“select?*?from?course?where?courseid=?“;
QueryRunner?qr?=?new?QueryRunner(jdbcUtils.getDataSource()?true);
object?param?=?courseId;
Course?course?=?qr.query(sql?new?BeanHandler(Course.class)?param);
if(course!=null){
return?true;
}
return?false;
}
/**修改課程信息
?*?@throws?SQLException?*/
public?int?changeCourseInfo(Course?course)?throws?SQLException{
String?sql1?=?“update?course?set?Cname=‘“+course.getCname()+“‘?where?courseid=‘“+course.getCourseid()+“‘“;
String?sql2?=?“update?course?set?period=‘“+course.getPeriod()+“‘?where?courseid=‘“+course.getCourseid()+“‘“;
String?sql3?=?“update?cours
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-12-19?23:19??IceStudent\
?????文件?????????846??2014-12-19?23:16??IceStudent\.classpath
?????文件????????1335??2014-11-29?21:54??IceStudent\.project
?????目錄???????????0??2014-12-19?23:19??IceStudent\.settings\
?????文件?????????522??2014-11-28?20:22??IceStudent\.settings\.jsdtscope
?????文件??????????57??2014-11-28?20:26??IceStudent\.settings\org.eclipse.core.resources.prefs
?????文件?????????598??2014-11-28?20:26??IceStudent\.settings\org.eclipse.jdt.core.prefs
?????文件?????????564??2014-11-30?00:18??IceStudent\.settings\org.eclipse.wst.common.component
?????文件?????????414??2014-11-28?20:22??IceStudent\.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件??????????49??2014-11-28?20:22??IceStudent\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件???????????6??2014-11-28?20:22??IceStudent\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????文件????????1345??2014-12-03?12:32??IceStudent\README.txt
?????目錄???????????0??2014-12-19?23:19??IceStudent\src\
?????文件????????1376??2014-12-02?16:07??IceStudent\src\c3p0-config.xm
?????目錄???????????0??2014-12-19?23:19??IceStudent\src\com\
?????目錄???????????0??2014-12-19?23:19??IceStudent\src\com\m2sa\
?????目錄???????????0??2014-12-19?23:19??IceStudent\src\com\m2sa\dao\
?????文件????????5806??2014-12-02?16:09??IceStudent\src\com\m2sa\dao\CourseDao.java
?????目錄???????????0??2014-12-19?23:19??IceStudent\src\com\m2sa\dao\domain\
?????文件????????1761??2014-12-01?20:09??IceStudent\src\com\m2sa\dao\domain\Course.java
?????文件????????2986??2014-12-19?23:12??IceStudent\src\com\m2sa\dao\domain\Page.java
?????文件????????2985??2014-12-19?23:12??IceStudent\src\com\m2sa\dao\domain\PageCourse.java
?????文件????????1183??2014-11-30?19:35??IceStudent\src\com\m2sa\dao\domain\Student.java
?????文件????????2051??2014-12-03?12:16??IceStudent\src\com\m2sa\dao\GradeDao.java
?????文件????????5571??2014-12-02?16:12??IceStudent\src\com\m2sa\dao\StudentDao.java
?????目錄???????????0??2014-12-19?23:19??IceStudent\src\com\m2sa\filter\
?????文件????????2239??2014-12-19?23:14??IceStudent\src\com\m2sa\filter\CharEncodingFilter.java
?????目錄???????????0??2014-12-19?23:19??IceStudent\src\com\m2sa\utils\
?????文件?????????574??2014-12-19?23:14??IceStudent\src\com\m2sa\utils\jdbcUtils.java
?????目錄???????????0??2014-12-19?23:19??IceStudent\src\com\m2sa\web\
?????文件????????2263??2014-12-01?23:30??IceStudent\src\com\m2sa\web\AddCourseServlet.java
............此處省略115個文件信息
評論
共有 條評論