0

JAVA PREPARED STATEMENT

HEY GUYS I M TRYING TO BUILD THE CHANGE PASSWORD DASHBOARD, BUT WHEN I'm USING SQL QUERY "WHERE" FOR MATCHING THE PERTICULAR SET OF ROW.AND WHEN I COMPILE THE CODE, IT SHOW the following error. so guys check the error and source file in comment box and try to resolve the problem. thanks in advance. ------------------------------------------------------------------------------------------------------------- java.sql.SQLException: Missing IN or OUT parameter at index:: 4 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1681)at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3280)at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368) at ChangePassword.doGet(ChangePassword.java:51) at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 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:475) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) at org.apache.catalina

5th Apr 2017, 10:58 PM
Pratul Tripathi
Pratul Tripathi - avatar
3 odpowiedzi
+ 1
import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class ChangePassword */ public class ChangePassword extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { try { res.setContentType("text/html"); PrintWriter pw=res.getWriter(); Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=DriverManager.getConnection( "jdbc:oracle:thin:@localhost:1521:xe","system","pratul"); PreparedStatement ps=con.prepareStatement("UPDATE USERREG set PASS=?,NEW_PASS=?,OLD_PASS=? WHERE NAME=?"); //String Name1=req.getParameter("NAME"); String Curr_Pass1=req.getParameter("PASS"); String New_Pass1=req.getParameter("NEW_PASS"); String Con_Pass1=req.getParameter("CON_PASS"); //ps.setString(1,Name1); ps.setString(1,New_Pass1); ps.setString(2,Con_Pass1 ); ps.setString(3,Curr_Pass1 ); int i=ps.executeUpdate(); if(i!=0&&New_Pass1.equals(Con_Pass1)){ System.out.println("PASSWORD HAS BEEN SUCCESSFULLY CHANGED" );} else{ System.out.println("NOT CHANGE TRY LATER"); } con.close(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } }
5th Apr 2017, 10:58 PM
Pratul Tripathi
Pratul Tripathi - avatar
0
1
6th Apr 2017, 11:09 AM
Vitaly Podgornov
Vitaly  Podgornov - avatar
0
Q
6th Apr 2017, 11:09 AM
Vitaly Podgornov
Vitaly  Podgornov - avatar