• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

doubt in update

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created 2 forms using swing in netbeans.first form helps to store the data entered in the form. second form contains 2 labels such as username and password, 2 textboxes and 2 buttons such as submit and update. if i click submit button , it checks the data entered with the database and if it matches, it display the dialog box-"Successfully". if i give new password and click update button,it should be updated.Here, is the program used for updating

My doubt is if i click update button , it displays Updated successfully, but it is not stored in the database. can you please tell why it is not storing?
 
Marshal
Posts: 79987
399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dhivya rajagopal wrote:I have created 2 forms using swing in netbeans.first form helps to store the data entered in the form. second form contains 2 labels such as username and password, 2 textboxes and 2 buttons such as submit and update. if i click submit button , it checks the data entered with the database and if it matches, it display the dialog box-"Successfully". if i give new password and click update button,it should be updated.Here, is the program used for updating

My doubt is if i click update button , it displays Updated successfully, but it is not stored in the database. can you please tell why it is not storing?

Is the database supposed to be storing the password as plain text rather than with the password() function? That seems odd.
Have you printed the rs value? Does it confirm you are actually updating anything?
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You seem to have got the order of the name and password the wrong way round. You're binding the contents of jPasswordField1 to the second parameter of the query, which is the name. So the UPDATE runs without error, but doesn't match against any records.
 
Dhivya rajagopal
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thank you brown and ritchie, now its updating. For example I gave dhivya in username and mita in text box and click update means it is store in the database. That form contains submit button, it checks for the data entered in the text box with the databases and if it matches then it will display "successful". if it doesn't match, then it will display "enter valid username and password".
after updating , if i give the same value in the textboxes and click submit button means it is displaying "enter valid username and password".can you tell me why?
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can we have a look on that code?
 
Dhivya rajagopal
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following is the code for submit button

The following is the code for update button:
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would be better to use PreparedStatement.



 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not related to your question - but why are you using an int as a flag? This is Java - it's got a boolean type for that sort of thing.

Swastik's right, though. It's much better to query exactly the record you need than it is to get all the users and loop round all of them.

(Edit: by the way, the reason your code is formatted poorly is that you're using a mixture of tabs and spaces. I'd recommend switching to using spaces all the time. A couple of the lines also had a huge number of spaces at the end of them, which was why it was messing up the page width here. I've removed them to stop that happening).
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic