分为 dao层 service层 servlet 层 连接数据库 jar包 连接数据库的 js
UserDao代码
package cn.hp.dao;
import cn.hp.util.JDBCUtils;
import java.sql.ResultSet;
import java.sql.SQLException;
public class UserDao {
public int selectByAccountAndPassword(String account, String password) {
String sql = "select count(*) from users where account=? and password=?";
Object[] objects = {account, password};
ResultSet resultSet = JDBCUtils.DQL(sql,objects);
int select=0;
try {
while (resultSet.next()){
select= resultSet.getInt(1);
}
}catch (SQLException e){
e.printStackTrace();
}
return select;
}
public int selectByAccount(String account) {
String sql = "select count(*) from users where account=? ";
Object[] objects = {account};
ResultSet resultSet = JDBCUtils.DQL(sql,objects);
int select=0;
try {
while (resultSet.next()){
select= resultSet.getInt(1);
}
}catch (SQLException e){
e.printStackTrace();
}
return select;
}
}
service层代码
package cn.hp.service;
import c