jsp db¿¡¼­ °ª °¡Á®¿À±â

mt22   
   Á¶È¸ 8814   Ãßõ 0    

my sql db 사용중이고 테이블은 이렇게 만들어져 있습니다.

이 db에서 id pw와 일치하는 cur 값을 가져오고 싶은데 코드를 어떻게 수정해야할까요



package com.munggu.org;

import java.beans.Statement;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.websocket.Session;

import javafx.scene.control.Alert;

import javax.sql.*;



@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

public LoginServlet() {
super();
}

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.getWriter().append("Served at: ").append(request.getContextPath());
}

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

HttpSession session = request.getSession();

RequestDispatcher rd = null;
ResultSet rs = null;
Connection conn = null;
PreparedStatement pstmt = null;
String 가입시간 = null;

try {
Class.forName("com.mysql.jdbc.Driver");

conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/2_1","root","1234");

String 아이디 = request.getParameter("id");
String 비밀번호 = request.getParameter("pw");

pstmt = conn.prepareStatement("SELECT * FROM MEMBER WHERE ID='" + 아이디 + "' AND PW='" + 비밀번호 + "'");
rs = pstmt.executeQuery();

Boolean 로그인확인 = false;
while(rs.next()) {
가입시간 = rs.getString("cur");
로그인확인 = true;
}

if(로그인확인) {
session.setAttribute("아이디", 아이디) ;
session.setAttribute("비밀번호", 비밀번호);
session.setAttribute("가입시간", 가입시간);

session.setMaxInactiveInterval(60*5);
response.sendRedirect("login.jsp");
}

} catch (Exception e) {
rd = request.getRequestDispatcher("error.jsp");
} finally{
try {
if(rs != null)
rs.close();
} catch (SQLException e) {

e.printStackTrace();
}
try {
if(pstmt != null)
pstmt.close();
} catch (SQLException e) {

e.printStackTrace();
}
try {
if(conn != null)
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}

rd.forward(request,response);
}
}


 


ªÀº±Û Àϼö·Ï ½ÅÁßÇÏ°Ô.
±èÁ¦¿¬ 2017-05
À̹̠ °¡ÀԽ𣿡  cur°ªÀÌ  °¡Á®¿Â°Í  °°Àºµ¥¿ä
     
Å©¸®ÇÇ 2017-05
Àß µÇ´ø°Ô Àú ÄÚµå Ãß°¡ÇÏ´Ï ¿À·ù¶ß³×¿ä
Äڵ忡 ¹®Á¦°¡ Àִ°Ű°¾Æ¿ä
±èÁ¦¿¬ 2017-05
Áö¹Ù´Â  ¾î¶»°Ô  µÇ¾ú´ÂÁö  ¸ð¸£Áö¸¸  rs['cur']ÀÌ·±½ÄÀ¸·Î  °¡Á®¿ÃÅÙµ¥¿ä  ¹è¿­À̸é
     
Å©¸®ÇÇ 2017-05
Àü¿¡ ¹Ù·Î jspÆÄÀÏ·Î ³Ñ±æ¶§´Â ÀÌ·¸°Ô ³Ñ°å´Âµ¥
¼¼¼ÇÀ¸·Î ³Ñ±â·Á´Ï Àß ¾ÈµÇ³×¿ä ¤Ð¤Ð


while(rs.next()){

mm.setName(rs.getString("name"));
mm.setGender(rs.getString("gender"));
mm.setAge(rs.getString("age"));
mm.setAddr(rs.getString("addr"));
mm.setCurrent(rs.getString("current"));

System.out.println(mm);

}
return mm;
          
±èÁ¦¿¬ 2017-05
µð¹ö±ëÇغ¸¼¼¿ä


QnA
Á¦¸ñPage 4797/5680
2014-05   4946878   Á¤ÀºÁØ1
2015-12   1483534   ¹é¸Þ°¡
2010-07   8716   ÀÌÇØÇϸé¿À¡¦
2018-04   8717   ¼ÛÁøÈ«
2014-08   8717   ¶ó¿ÂÁ¦³ª
2013-12   8717   À©µµ¿ì10
2003-12   8717   À¯»óÇÏ
2011-02   8718   °Ç»§¸Ç
2003-09   8718   ±Ç¿µµ·
2011-04   8718   ±×·¡ÇǾÆ
2010-11   8718   Á¤ÀºÁØ1
2003-07   8718   °­¹ÎÈ£
2010-09   8718   klein
2011-05   8719   ¹Ú°æÈ£
2004-03   8719   Á¤ÀçÈÆ
2010-01   8719   analogue±è¡¦
2011-01   8719   ±èÁÖ¿ës
2004-04   8720   Á¤ÀçÈÆ
2014-03   8720   º´¸ÀÆù
2009-01   8720   À±¿µ¹è
2003-06   8721   ÀÌÁ¤ÁÖ
2005-02   8721   À±ÁØÇü