简体   繁体   中英

Account is getting locked if we give wrong password at 3rd attempt in mysql while at 4th attempt in oracle with same query?

In these queries we are checking success and failed case .

In success case : counter is 0 as no incorrect password hence locked field is 'f'

In failure case : Every time password is incorrect. counter will increment by 1 and locked if it is greater than 3 .

in mysql it is locking at 3rd attempt(it should lock at 4th attempt) while in oracle it is locking at 4th attempt only (working fine in oracle)

Can we change query in such a way so that it works for both mysql and oracle ?

In this query :

<statement name="contentprovider-failed"
  statement="update MDB_APPLICATION_NODE_PR set COUNTER=COUNTER+1, LOCKED= case when COUNTER &lt; ? 
                                    then 'f' else 't' end where USERNAME=?">

This is the whole code contain success and failure case :

<statement name="contentprovider-succeed"
        statement="update MDB_APPLICATION_NODE_PR set COUNTER=0, LOCKED='f' where USERNAME=?">
        <param type="varchar"/>
</statement>

Can we change query in such a way so that it works for both mysql and oracle ?

or how will check that increment counter in java and thn passed as a '?' parameter in query ?

Clearly, MySQL is using the updated value of COUNTER in the comparison and Oracle is not. (I've verified that behavior in MySQL, and MySQL documents it for single-table updates. I don't have a copy of Oracle lying around. I can tell you SQL Server doesn't do what MySQL does.)

Probably safest to code it as two statements, update COUNTER , then separately update the LOCKED . (Then use 4 in your config file instead of 3 .)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM