Kunal Lakhani wrote:I have successfully executed other applications relating to insert , update, deleting the data. So, there is some problem with this code.
I see that at org.Cmtes.Imm.Dao.UserDao.authenticateUser(UserDao.java:17) is the cause for this exception (from the stacktrace)
yes, you were right. line no 17 was the cause. I didn't included user and password for db connection.
Now, after adding scott and tiger as user and password, the following stack trace is displayed:
java.sql.SQLException: ResultSet.next was not called
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:387)
at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1515)
at org.Cmtes.Imm.Dao.UserDao.authenticateUser(UserDao.java:21)
at org.Cmtes.Imm.Servlet.UserLoginServlet.doPost(UserLoginServlet.java:30)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Line 20 in UserDao.java is the culprit. As Paul has already mentioned how to go about accessing the values from the ResultSet. At line 20 you are trying to get the username even before the cursor is pointing to actual data from the table.