Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with GUI SQL Login.

 
Dave Dix
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so I have 2 issues, first off is I am trying to figure out this code I found here http://www.roseindia.net/tutorial/java/core/storeEncryptedPassword.html so that I can encrypt and decrypt the passwords that I use...however they do not have much of a "tutorial" its pretty much just "hey look its code" and that is just a bit overwhelming for me as I only started working with java really today. (have used it before but not on this scale, manly pservers that use a java base or something)


Any help on that would be great, now the real issue I am having is that I am working on the login page of my project and want to have it decrypt then check the password and username and then if correct, hide itself with a connected text or something whatever.
Anywho I am having trouble figuring out how to grab the values from one class that takes them from the mySQL DB and then hand them to the other so that I can use an if statement to confirm its a valid user. here is my code, hopefully you can see what I am messing up.



 
E Armitage
Rancher
Posts: 989
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.) Do not use RoseIndia. Use other resources and texts that have more consistently accurate and helpful information.
2.) Do not encrypt/decrypt user passwords. Hash them instead (https://www.owasp.org/index.php/Hashing_Java). That way even system admins can't find out user passwords
3.) Do not use Netbeans genearted code if you are learning swing. Write out your interfaces manually so you know exactly what's going on.
4.) Read and try to understand the error messages that you get when you try to compile/run your code. You will learn a lot from them.
5.) One of your methods has code like this



The line is not valid Java syntax as it is trying to call a method but is declaring the type of the arguments with.

Then the line is trying to compare text fields to values that have not yet been properly declared. this suggests that you should revise your notes on simple method declarations, how to call methods and how to declare variables inside methods before you try to write swing code or code that connects to databases.
6.) You should also read the JDBC tutorial ( here http://docs.oracle.com/javase/tutorial/jdbc/basics/) before proceeding with the database code.
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
+1 to everything E has said. One minor addition though:

E Armitage wrote:Then the line is trying to compare text fields to values that have not yet been properly declared.

One equal sign (=) is an assignment operator, two (==) is an equality operator. But you should not use == anyway, except to compare primitive types. When comparing anything else (especially Strings), use the equals method. See AvoidTheEqualityOperator.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic