회원가입 DB 연동
This commit is contained in:
@@ -43,16 +43,24 @@ public class UserJoinDao extends BasicDao {
|
||||
UserJoinVo vo = null;
|
||||
|
||||
try {
|
||||
this.psmt = this.conn.prepareStatement("SELECT * FROM user_tbl WHERE id = ? and pw = ?");
|
||||
this.psmt.setString(1, member.getU_ID());
|
||||
this.psmt = this.conn.prepareStatement("SELECT * FROM user_tbl WHERE u_ID ='?' and u_psw ='?'");
|
||||
//this.psmt = this.conn.prepareStatement("SELECT u_ID, u_psw FROM user_tbl");
|
||||
|
||||
// while(this.rs.next()) {
|
||||
// member = new UserJoinVo();
|
||||
//member.setU_ID(this.rs.getString("u_ID"));
|
||||
//member.setU_psw(this.rs.getString("u_psw"));
|
||||
//}
|
||||
this.psmt.setString(1, member.getU_ID());
|
||||
this.psmt.setString(2, member.getU_psw());
|
||||
this.rs = this.psmt.executeQuery();
|
||||
this.rs = this.psmt.executeQuery();
|
||||
if (this.rs.next()) {
|
||||
vo = new UserJoinVo();
|
||||
// vo = new UserJoinVo();
|
||||
String id = this.rs.getString("u_ID");
|
||||
String pw = this.rs.getString("u_pwd");
|
||||
vo.setU_ID(id);
|
||||
vo.setU_psw(pw);
|
||||
String pw = this.rs.getString("u_psw");
|
||||
vo = new UserJoinVo(id, pw); // 이거 왜 이러냐 개샤ㅐ끼야
|
||||
//vo.setU_ID(id);
|
||||
//vo.setU_psw(pw);
|
||||
}
|
||||
} catch (SQLException var5) {
|
||||
var5.printStackTrace();
|
||||
|
||||
@@ -12,6 +12,8 @@ public class UserJoinVo {
|
||||
public String u_divi;
|
||||
public String u_car_num;
|
||||
|
||||
|
||||
|
||||
public String getU_ID() {
|
||||
return u_ID;
|
||||
}
|
||||
|
||||
34
hospital/src/main/java/command/UserLoginCheckCommand.java
Normal file
34
hospital/src/main/java/command/UserLoginCheckCommand.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package command;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import UserJoin.UserJoinDao;
|
||||
import UserJoin.UserJoinVo;
|
||||
|
||||
public class UserLoginCheckCommand implements Command {
|
||||
|
||||
public String exec(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
UserJoinDao dao = new UserJoinDao();
|
||||
UserJoinVo member = null;
|
||||
String id = request.getParameter("u_ID");
|
||||
String pw = request.getParameter("u_psw");
|
||||
System.out.println("u_ID : " + id);
|
||||
System.out.println("u_psw : " + pw);
|
||||
id = id.trim();
|
||||
pw = pw.trim();
|
||||
member = dao.selectMember(member);
|
||||
request.setAttribute("member", member);
|
||||
String path;
|
||||
if (member != null) {
|
||||
path = "loginOk.jsp";
|
||||
} else {
|
||||
path = "loginFail.jsp";
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import command.BoardViewCommand;
|
||||
import command.Command;
|
||||
import command.HomeCommand;
|
||||
import command.UserJoinCommand;
|
||||
import command.UserLoginCheckCommand;
|
||||
import command.UserLoginCommand;
|
||||
import command.UserRegCommand;
|
||||
import command.patientJoinCommand;
|
||||
@@ -40,6 +41,7 @@ public class Fcontroller extends HttpServlet {
|
||||
list.put("/UserReg.do", new UserRegCommand()); // 임직원 회원가입 페이지
|
||||
list.put ("/patientJoin.do", new patientJoinCommand()); // 환자 회원가입 페이지
|
||||
list.put("/boardView.do", new BoardViewCommand()); // 데이터 보기 test 페이지
|
||||
list.put("/loginCheck.do", new UserLoginCheckCommand());
|
||||
//이 부분에 계속적으로 매핑을 추가하면 됨
|
||||
|
||||
}
|
||||
|
||||
5
hospital/src/main/java/patientJoin/patientJoinDao.java
Normal file
5
hospital/src/main/java/patientJoin/patientJoinDao.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package patientJoin;
|
||||
|
||||
public class patientJoinDao {
|
||||
|
||||
}
|
||||
5
hospital/src/main/java/patientJoin/patientJoinVo.java
Normal file
5
hospital/src/main/java/patientJoin/patientJoinVo.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package patientJoin;
|
||||
|
||||
public class patientJoinVo {
|
||||
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package user;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import DB.BasicDao;
|
||||
import user.UserVo;
|
||||
|
||||
public class UserDao extends BasicDao {
|
||||
private final String MEMBER_LIST = "SELECT * FROM member";
|
||||
private final String MEMBER_CHECK = "SELECT * FROM member WHERE id = ? and pw = ?";
|
||||
private final String MEMBER_INSERT = "INSERT into member values(?,?,?,?,?,?,?)";
|
||||
|
||||
public ArrayList<UserVo> select() {
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
try {
|
||||
this.psmt = this.conn.prepareStatement("SELECT * FROM member");
|
||||
this.rs = this.psmt.executeQuery();
|
||||
|
||||
while(this.rs.next()) {
|
||||
UserVo member = new UserVo();
|
||||
member.setId(this.rs.getString("ID"));
|
||||
member.setName(this.rs.getString("NAME"));
|
||||
member.setAddr(this.rs.getString("ADDR"));
|
||||
member.setTel(this.rs.getString("TEL"));
|
||||
member.setGender(this.rs.getString("GENDER"));
|
||||
member.setHobby(this.rs.getString("HOBBY"));
|
||||
list.add(member);
|
||||
}
|
||||
} catch (SQLException var3) {
|
||||
var3.printStackTrace();
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public UserVo selectUser(UserVo user) {
|
||||
UserVo vo = null;
|
||||
|
||||
try {
|
||||
this.psmt = this.conn.prepareStatement("SELECT * FROM member WHERE id = ? and pw = ?");
|
||||
this.psmt.setString(1, user.getu_ID());
|
||||
this.psmt.setString(2, user.getPw());
|
||||
this.rs = this.psmt.executeQuery();
|
||||
if (this.rs.next()) {
|
||||
String id = this.rs.getString("id");
|
||||
String pw = this.rs.getString("pw");
|
||||
vo = new userVo(id, pw);
|
||||
}
|
||||
} catch (SQLException var5) {
|
||||
var5.printStackTrace();
|
||||
}
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
public int memberInsert(MemberVo member) {
|
||||
int n = 0;
|
||||
|
||||
try {
|
||||
this.psmt = this.conn.prepareStatement("INSERT into member values(?,?,?,?,?,?,?)");
|
||||
this.psmt.setString(1, member.getId());
|
||||
this.psmt.setString(2, member.getName());
|
||||
this.psmt.setString(3, member.getPw());
|
||||
this.psmt.setString(4, member.getAddr());
|
||||
this.psmt.setString(5, member.getTel());
|
||||
this.psmt.setString(6, member.getGender());
|
||||
this.psmt.setString(7, member.getHobby());
|
||||
n = this.psmt.executeUpdate();
|
||||
} catch (SQLException var4) {
|
||||
var4.printStackTrace();
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package user;
|
||||
|
||||
public class UserVo {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user