2020-06-05-----java.sql.SQLException: No value specified for parameter 3

11638 단어 JavaWeb

Javaweb 실행 항목 오류 No value specified for parameter 3


세 번째 매개변수에는 값이 없습니다.그러나 나는 n여 차례 자신의 코드를 검사한 결과 세 번째 파라미터도 없고 잘못 쓴 괄호도 없었다. 어떻게 고쳐도 이 오류 알림이었다.하지만 결국 잘못된 점은 SQL 문장에 있을 것이다.
java.sql.SQLException: No value specified for parameter 3
  sql    
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1115)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1040)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1347)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:1025)
	at com.jdbc.DButil.DButil.update(DButil.java:128)
	at com.jdgl.service.JdService.updateRoom(JdService.java:315)
	at com.jdgl.servlet.UpdateRoomServlet.doPost(UpdateRoomServlet.java:28)
	at com.jdgl.servlet.UpdateRoomServlet.doGet(UpdateRoomServlet.java:18)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:688)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:609)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1623)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)

유용한 오류 정보는 아래의 몇 마디밖에 없다
java.sql.SQLException: No value specified for parameter 3
at com.jdbc.DButil.DButil.update(DButil.java:128)
	at com.jdgl.service.JdService.updateRoom(JdService.java:315)
	at com.jdgl.servlet.UpdateRoomServlet.doPost(UpdateRoomServlet.java:28)
	at com.jdgl.servlet.UpdateRoomServlet.doGet(UpdateRoomServlet.java:18)

처음에 제 SQL 문구는요.
String sql = "update room set room_num=?,room_price=? where room_num=";

수정된 SQL 문은
String sql = "update room set room_num=?,room_price=? where room_num="+roomNum;

수정한 방 번호였구나. 안 왔어.정말 며칠 동안의 잘못을 망설였다.
마지막으로 말하고 싶은 것은 프로그램 백에 대해 오류를 수정할 때 몇 개의 출력 문구를 더 많이 사용해서 오류를 감지할 수 있도록 권장하는 것이다.

좋은 웹페이지 즐겨찾기