package org.user.dao.impl;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.dao.user.IusersDao;
import org.student.Util.DBUtils;
import org.student.entity.Student;
import org.user.Util.usersDBUtils;
import org.user.entity.Bjedu;
import org.user.entity.BookName;
import org.user.entity.BookScore;
import org.user.entity.Users;
import org.user.entity.liuyan;
import org.user.entity.totalman;
public class usersdaoImpl implements IusersDao{
public boolean isExist(String username) {
return QueryUserBySon(username)!=null?true:false;
}
public boolean isLiuyanExist(String username) {
return QueryLiuyanByUsername(username)!=null?true:false;
}
public boolean isBookScoreExist(String username,String bookname) {
if(QueryBookScoreByUsername(username)!=null?true:false) {
BookName ceshi = null;
ArrayList<String> arr = new ArrayList<String>();
boolean result = true;
ceshi = BookNameByUsername(username);
arr=ceshi.getBookname();
for(int i = 0;i<arr.size();i++) {
if(arr.get(i).equals(bookname)) {
result = false;
}
}
return result;
}
return true;
}
public int AddUsers(Users user){
String sql = "insert into yonghu values(?,?,?)";
Object params[] = {user.getUsername(),user.getPassword(),user.getUserpwd()};
return usersDBUtils.executeUpdate(sql, params);
}
public int AddBookScore(BookScore bookscore){
String sql = "insert into bookscore values(?,?,?)";
Object params[] = {bookscore.getUsername(),bookscore.getBookname(),bookscore.getScore()};
return usersDBUtils.executeUpdate(sql, params);
}
public int AddLiuyan(liuyan liuyan){
String sql = "insert into liuyan values(?,?,?,?)";
Object params[] = {liuyan.getUsername(),liuyan.getAge(),liuyan.getSex(),liuyan.getTextarea()};
return usersDBUtils.executeUpdate(sql, params);
}
public liuyan QueryLiuyanByUsername(String username) {
liuyan liuyan = null;
ResultSet rs = null;
try {
String sql = "select * from liuyan where username = ?";
Object params[] = {username};
rs = usersDBUtils.executeQuery(sql, params);
if(rs.next()) { //当只有一条记录时,使用if
String uname =rs.getString("username");
int age =rs.getInt("age");
String sex = rs.getString("sex");
String textarea = rs.getString("textarea");
liuyan = new liuyan(uname,age,sex,textarea);
}
return liuyan;
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
catch(SQLException e) {
e.printStackTrace();
return null;
}
catch(Exception e) {
e.printStackTrace();
return null;
}
finally {
try {
if(usersDBUtils.conn!=null)usersDBUtils.conn.close();
if(usersDBUtils.pstmt!=null)usersDBUtils.pstmt.close();
if(rs!=null)rs.close();
}catch(SQLException e) {
e.printStackTrace();
}
}
}
public int GetBookScoreByBookName(String username,String bookname){
String sql = "select count(1) from bookscore where username= ? and bookname= ? ";
Object params[] = {username,bookname};
return usersDBUtils.getBookScoreByBookName(sql, params);
}
public BookName BookNameByUsername(String username) {
ArrayList<String> result = new ArrayList<String>();
BookName bn = null;
ResultSet rs = null;
try {
String sql = "select bookname from bookscore where username = ?";
Object params[] = {username};
rs = usersDBUtils.executeQuery(sql, params);
while(rs.next()) { //当只有一条记录时,使用if
String uname =rs.getString(1);
result.add(uname);
}
bn = new BookName(result,username);
return bn;
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
catch(SQLException e) {
e.printStackTrace();
return null;
}
catch(Exception e) {
e.printStackTrace();
return null;
}
finally {
try {
if(usersDBUtils.conn!=null)usersDBUtils.conn.close();
if(usersDBUtils.pstmt!=null)usersDBUtils.pstmt.close();
if(rs!=null)rs.close();
}catch(SQLException e) {
e.printStackTrace();
}
}
}
public BookScore QueryBookScoreByUsername(String username) {
BookScore bookscore = null;
ResultSet rs = null;
try {
String sql = "select * from bookscore where username = ?";
Object params[] = {username};
rs = usersDBUtils.executeQuery(sql, params);
if(rs.next()) { //当只有一条记录时,使用if
String uname =rs.getString("username");
String bookname = rs.getString("bookname");
int score = rs.getInt("score");
bookscore = new BookScore(uname,bookname,score);
}
return bookscore;
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
catch(SQLException e) {
e.printStackTrace();
return null;
}
catch(Exception e) {
e.printStackTrace();
return null;
}
finally {
try {
if(usersDBUtils.conn!=null)usersDBUtils.conn.close();
if(usersDBUtils.pstmt!=null)usersDBUtils.pstmt.close();
if(rs!=null)rs.close();
}catch(SQLException e) {
e.printStackTrace();
}
}
}
public List<liuyan> queryliuyanPage(int currentPage, int pageSize) {
List<liuyan> liuyans = new ArrayList<liuyan>();
liuyan liuyan = null;
ResultSet rs = null;
// String sql = "select * from"
// +"("
// +"select rownum r,t.* from"
// +"(select s.* from liuyan s order by age asc) t"
// +" where rownum<=?"
// +")"
// +"where r>=?"
// ;
String sql="select * from liuyan limit ?,?";
//Object[] params = {currentPage*pageSize,(currentPage-1)*pageSize+1};
Object[] params = {currentPage*pageSize,pageSize};
try {
rs = usersDBUtils.executeQuery(sql, params);
// TODO Auto-generated method stub
while(rs.next()) { //当只有一条记录时,使用if
String uname = rs.getString("username");
int age = rs.getInt("age");
String sex =rs.getString("sex");
String textarea=rs.getString("textarea");
liuyan = new liuyan(uname,age,sex,textarea);
liuyans.add(liuyan);
}
return liuyans;
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
finally {
try {
if(usersDBUtils.conn!=null)usersDBUtils.conn.close();
if(usersDBUtils.pstmt!=null)usersDBUtils.pstmt.close();
if(rs!=null)rs.close();
}catch(SQLException e){
e.printStackTrace();
}
}
}
public List<BookScore> QueryAllBookScore() {
List<BookScore> bookscores = new ArrayList<BookScore>();
BookScore bookscore = null;
ResultSet rs = null;
String sql="select * from bookscore";
Object[] params = null;
try {
rs = usersDBUtils.executeQuery(sql, params);
// TODO Auto-generated method stub
while(rs.next()) { //当只有一条记录时,使用if
String uname = rs.getString("username");
String bookname =rs.getString("bookname");
int score=rs.getInt("score");
bookscore = new BookScore(uname,bookname,score);
bookscores.add(bookscore);
}
return bookscores;
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
finally {
try {
if(usersDBUtils.conn!=null)usersDBUtils.conn.close();
if(usersDBUtils.pstmt
没有合适的资源?快使用搜索试试~ 我知道了~
漫画推荐系统javaweb
共225个文件
png:77个
class:37个
java:37个
需积分: 50 11 下载量 63 浏览量
2020-03-23
16:02:02
上传
评论
收藏 6.33MB RAR 举报
温馨提示
<h2>系统环境</h2> <p>系统环境:Windows</p> <p>开发工具:Eclipse</p> <p>Java版本:JDK 1.8</p> <p>服务器:tomcat 9.0</p> <p>数据库:MySQL 5.1</p> <p>系统采用技术: Servlet+Jsp+Jdbc+dbutils+EasyUI+jQuery+Ajax+面向接口编程</p>漫画推荐系统,模板改的很垃圾,里面很多东西没有弄完不过看着改改还能看
资源推荐
资源详情
资源评论
收起资源包目录
漫画推荐系统javaweb (225个子文件)
usersdaoImpl.class 16KB
StudentDaoimpl.class 6KB
usersDBUtils.class 4KB
DBUtils.class 4KB
Upload.class 4KB
Bjedu.class 4KB
UsersServiceimpl.class 3KB
dengluServlet.class 3KB
BookScoreServlet.class 3KB
QueryAllEduByPage.class 3KB
addliuyan.class 2KB
QueryAllTotalManByPage.class 2KB
QueryliuyanByPage.class 2KB
zhuceServlet.class 2KB
UpdateStudentServlet.class 2KB
KeynameServlet.class 2KB
AddStudentServlet.class 2KB
DeleteStudentServlet.class 2KB
StudentServiceimpl.class 2KB
Student.class 2KB
QueryAllBookScore.class 2KB
TotalmanPage.class 2KB
QueryStudentBySon.class 2KB
liuyanPage.class 2KB
Page.class 2KB
QueryAllEdu.class 2KB
QueryAllStudent.class 2KB
Users.class 1KB
QueryStudentByPage.class 1KB
totalman.class 1KB
IusersDao.class 1KB
liuyan.class 1KB
BookScore.class 1KB
BookName.class 966B
IUsersService.class 952B
IStudentDao.class 622B
IStudentService.class 593B
.classpath 1KB
org.eclipse.wst.common.component 491B
org.eclipse.wst.jsdt.ui.superType.container 49B
style1.css 26KB
layer.css 11KB
layim.css 11KB
laydate.css 6KB
style.css 4KB
laydate.css 3KB
laydate.css 3KB
layer.ext.css 3KB
style.css 1KB
zhucestyle.css 1KB
loading-0.gif 6KB
xubox_loading0.gif 6KB
xubox_loading3.gif 2KB
xubox_loading2.gif 2KB
loading-2.gif 2KB
xubox_loading1.gif 701B
loading-1.gif 701B
loading.gif 166B
ojdbc8.jar 3.97MB
mysql-connector-java-5.0.8-bin.jar 528KB
mysql-connector-java-5.0.8-bin.jar 528KB
servlet-api.jar 277KB
commons-io-2.3.jar 178KB
commons-io-2.3.jar 178KB
commons-fileupload-1.3.1.jar 67KB
commons-fileupload-1.3.1.jar 67KB
usersdaoImpl.java 15KB
StudentDaoimpl.java 6KB
usersDBUtils.java 4KB
Bjedu.java 3KB
DBUtils.java 3KB
Upload.java 3KB
UsersServiceimpl.java 2KB
dengluServlet.java 2KB
AddStudentServlet.java 2KB
BookScoreServlet.java 2KB
zhuceServlet.java 2KB
addliuyan.java 2KB
QueryAllTotalManByPage.java 2KB
QueryAllEduByPage.java 2KB
QueryliuyanByPage.java 2KB
Page.java 2KB
UpdateStudentServlet.java 2KB
KeynameServlet.java 2KB
Student.java 2KB
StudentServiceimpl.java 1KB
TotalmanPage.java 1KB
liuyanPage.java 1KB
IusersDao.java 1KB
QueryAllBookScore.java 1KB
DeleteStudentServlet.java 1KB
QueryStudentBySon.java 1KB
QueryAllEdu.java 1KB
QueryAllStudent.java 1KB
QueryStudentByPage.java 1021B
IUsersService.java 893B
Users.java 849B
liuyan.java 822B
IStudentDao.java 786B
totalman.java 747B
共 225 条
- 1
- 2
- 3
资源评论
wy983391528
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功