작성
·
193
0
/Hello World/WebConetnt/WEB-INF/lib/mysql-connector-j-8.3.0.jar
해당드라이버 lib 폴더에 넣고 실행하였는데
No value specified for parameter 2 에러가 발생합니다.
=====
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:130)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1077)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1003)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1312)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:988)
at user.UserDAO.join(UserDAO.java:17)
====
package user;
import java.sql.Connection;
import java.sql.PreparedStatement;
import util.DatabaseUtil;
public class UserDAO {
public int join(String userID, String userPassword) {
String SQL = "INSERT INTO USER VALUES (?,?)";
try {
Connection conn = DatabaseUtil.getConnection();
PreparedStatement pstmt = conn.prepareStatement(SQL); // SQL에 ID와 PW를 넣어 줄 수 있도록 Setting
pstmt.setString(1, userID);
pstmt.setString(1, userPassword);
return pstmt.executeUpdate(); // INSERT 구문을 실행해서 나온 결과를 반환하도록 해준다.
// 반환값 : INSERT된 데이터 갯수
} catch(Exception e){
e.printStackTrace();
}
return -1;
}
}