Java Authentication user name, password

Source: Internet
Author: User

1. Database Operations 2. Verify user 2.1. Inquire
String sql = String.Format ("SELECT count (*) from user where name= '%s ' and password= '%s ');" , UserName,                    userpass); int row = 0; jb.queryforobject (sql, Integer. class, row);

The user is judged by the value of row.

2.1. Error
Parameter index out of range (1 > number of parameters, which is 0)
2.1.1. SQL statements

No problem after the test.

2.1.2. Guess a

The format statement was wrong and was found right after the check

2.1.3. Guessing two

int changed to integer, not changed

2.1.4. Or start with the hint itself

It's like saying Jb.queryforobject (sql, Integer.class, row); There is a problem. Check online, instead:

Integer row = (integer) jb.queryforobject (                    "SELECT COUNT (*) from user where name=? and password=?",new
     object[] {userName, userpass},                        Java.lang.Integer. class);
    • It worked!!!
    • '%d ' or '? ' to change ?
    • It should be thought that the connection was successful and that the error was on the query.

Java Authentication user name, password

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.