jsp Prepared Dtatement 사용할려고 합니다.
지금은 jsp와 db는 오라클을 쓰고있습니다. 가용방법좀 알려주세요
<%@page import="com.mysql.jdbc.PreparedStatement"%>
<%@page import="com.sun.xml.internal.bind.v2.schemagen.xmlschema.List"%>
<%@ page import="java.sql.*" language="java"
contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.io.*"%>
<%!boolean isIdExist = false;%>
<%
// 요청시 한글 처리
request.setCharacterEncoding("UTF-8");
// 요청시 한글처리
response.setContentType("text/html;charset=UTF-8");
// 요청한 곳으로부터 파라미터 받기
String u_id = request.getParameter("id");
String u_pwd = request.getParameter("pwd");
Connection con = null;
Statement st = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@211.227.000.000:.0001521:orcl";
String db_id = "scott";
String db_pw = "qwe123";
con = DriverManager.getConnection(url, db_id, db_pw);
st = con.createStatement();
String sql = "select*from member1";
rs = st.executeQuery(sql);
while (rs.next()) {
String id = rs.getString("id");
String pwd = rs.getString("pwd");
String name = rs.getString("name");
String phone = rs.getString("reg_date");
String msg = "";
if (id.equals(u_id)) {
isIdExist = true;
if (pwd.equals(u_pwd)) {
out.println(name + "님 로그인되었습니다. 환영합니다.");
sql = "update member2 set day = '1' where id ='?'";
//pstmt = con.createStatement(sql);이쪽부분입니다.
pstmt.setString(1, u_id);
} else {
out.println("비밀번호가 틀렸습니다.");
}
}
}
if (!isIdExist) {
out.println("아이디가 틀렸습니다.");
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
if (rs != null)
rs.close();
if (st != null)
st.close();
if (con != null)
con.close();
if(pstmt != null)
pstmt.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
%>
ㄴㅇ
주석처리한 부분 pstmt = con.createStatement(sql); 이렇게 쓰는건지 알고 싶습니다.
이렇게 쓰면 The method createStatement() in the type Connection is not applicable for the arguments (String) 이런 오류가 뜸니다 확인 방법 좀 사용방버좀 ㅜㅜ