jQuery in Action, 2nd edition*
The moose likes JDBC and the fly likes Not authenticating the user Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Not authenticating the user" Watch "Not authenticating the user" New topic
Author

Not authenticating the user

Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
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





kunal
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

Can you provide the Stacktrace?


Mohamed Sanaulla | My Blog
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

why not change to:
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
The application posted above shows the following stack trace :

Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

Please cross check the connection String in line 17 of UserDao.java.
Kunal Lakhani
Ranch Hand

Joined: Jun 05, 2010
Posts: 622
mohamed sanaullah, I don't find any mistake there. you please look into that once
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

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

Joined: Jun 05, 2010
Posts: 622
i am using Oracle 10g. That's ok as other applications are working
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

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

Joined: Jun 05, 2010
Posts: 622
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

Joined: Sep 08, 2007
Posts: 3068
    
  33

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

Joined: Jun 05, 2010
Posts: 622
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

Joined: Apr 14, 2004
Posts: 10336

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


  • JavaRanch FAQ HowToAskQuestionsOnJavaRanch
    Mohamed Sanaulla
    Saloon Keeper

    Joined: Sep 08, 2007
    Posts: 3068
        
      33

    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.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Not authenticating the user
     
    Similar Threads
    Always responding invalidLogin.jsp
    How this code can be improved?
    How to use httpsession with dao factory
    smtp mail server
    password hashingsalting in struts