Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with the "where" query.

 
Deepti Gupta
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm developing a small module and i'm facing a simple problem which i'm not able to solve.
I've to update my databse using the inputs from a JSP page.
the code for the updation is as follows:


now in the line:

when i'm giving a constant after the "where" clause its working completely fine. But when i'm sending a variable using
or any other method its not working properly and is redirecting back to the jsp page to enter the details to be updated.

Please help
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does oldusernme contain ? Did you try to debug it ? I see you have a setter method with a funny name : void OldUsername(String value). Shouldn't this be void setOldUsername(String value) ?
 
Deepti Gupta
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The oldusernme contains the user name that has to be updated. The update option gives us the facility to change the user name as well.

I've corrected the mistake and now it is void setOldUsername(String value)
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Debug updateString. What does it contain ?
 
Deepti Gupta
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm not using any IDE or editor. i'm using simple notepad. So i dont have any idea as to how to debug it.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's ok. Use System.out.println(updateString); , and check the output logs.
 
Deepti Gupta
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you suggest me where to use the System.out.println(updateString);

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to check the content of the SQL, so :
 
Deepti Gupta
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that the page gets redirected to either the update page or the gets directed to the page that has to be opened after the success of the operation. So i'm not able to see anything thats being printed. I need to hold the page from getting redirected.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure ? Did you check the logs ? I'm not talking about the web browser. Check the logs of your web container.
 
Deepti Gupta
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what it is showing in the logs:
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it looks fine Do you still have a user whose username is 'deepti' in your database ?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I smell the problem. You first executed :

This updated the 'deepti' user's username to a new name. Now there is no user called 'deepti' anymore. As I said in my previous post, check the database.
 
Deepti Gupta
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its working fine when i'm passing a constant after the where clause. But i need to pass a variable instead. I mean the code is:



its not working then and the log shows:


see.. its not passing the oldusername to the database
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a new step towards the solution oldusernme is null. Which means that setOldUsername is probably not called. You are using struts. What is the name of the input textfield ? Can you post your jsp file (or whatever file it is) as well ?
 
Deepti Gupta
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya sure.

This is my JSP file from where i'm sending the inputs:


and this is the JAVA file:
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your field is called "oldusername", so the getter/setter should be respectively called getOldusername and setOldusername (note that the 'u' is not capitalized).
 
Deepti Gupta
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made the changes you suggested... but its still not working.

I am unable to give you the log since there is some problem with it and its not responding
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepti Gupta wrote:I made the changes you suggested... but its still not working.

I am unable to give you the log since there is some problem with it and its not responding


Mmmhh... Restart the web container.
 
Deepti Gupta
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did.. I even restarted my machine twice...
but still its not responding.
The problem started after I used the System.out.println statement for checking the value of the password for the login page. The login pages is not logging after that and it is taking time to load that finally i have to cancel the process.
 
Deepti Gupta
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just solved the problem with my log.

now it is:


The problem still remains
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After opening the log file, did you leave it open ? If yes, close it.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, make the setOldusername public :
 
Deepti Gupta
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is still there:

 
Deepti Gupta
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
solved....


Thanks...
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm glad it's fixed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic