Am new to java.How can I solve this small problem? Am using database based authentication to enable mi logon.Am trying to compare the username and passfield fields but I dont know the best conditional operator/logic operator to use. Here is my sample code that contains a red wavy underline in the Netbeans IDE am using.

If (userName !false) && (password !true)
System.out.println("Invalid Password")

Please can anyone show me the right way to do that?
Thanks.

Recommended Answers

All 2 Replies

Telling you the solution will not solve anything. Net Beans tell you where the error is and what is the problem. If you can't fix it then I would suggest to stop what you are doing and start by reading very, very basic tutorials and try to learn simple basic core java and programming.

I believe that what you are trying to do is too advanced for the skills you have, so it is better to study a bit more.

Also if you want authentication, You need to compare the username given with the one that the query returns. You only have one username in your if expression and you are trying to find it out if it is false or not. I don't think that username can be neither true nor false, because I assume that username is a String. Comparing the username given with the one that the query returns will result true or false.
The same applies for password

well, even if he got it to compile it would never yield the result he's looking for...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.