Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not authenticating the user

 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am Providing a bean class, dao and servlet.
My database contains a table named 'users' which contains USERNAME & PASSWORD Columns.

On running this application in tomcat, its showing "Illegal argument in call"

what is wrong in this code?

UserLoginBean.java:





UserDao





UserLoginServlet




 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you provide the Stacktrace?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why not change to:
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The application posted above shows the following stack trace :

 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please cross check the connection String in line 17 of UserDao.java.
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mohamed sanaullah, I don't find any mistake there. you please look into that once
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this "jdbc:oracle:thin:@localhost:1521:oracle" supposed to be this : "jdbc:oracle:thin:@localhost:1521:orcl"

Update: Which version/type of Oracle Database are you using?
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using Oracle 10g. That's ok as other applications are working
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kunal Lakhani wrote:i am using Oracle 10g. That's ok as other applications are working


Which are the other applications?

I searched around on the web and found that the connection string format is supposed to be:

 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have successfully executed other applications relating to insert , update, deleting the data. So, there is some problem with this code.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like you are trying to use the ResultSet before you have move the cursor on. The normal pattern is:
  • Create a ResultSet
  • Move the cursor to the first result
  • Access a value from the ResultSet
  •  
    Mohamed Sanaulla
    Saloon Keeper
    Posts: 3159
    33
    Google App Engine Java Ruby
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic