简体   繁体   中英

Cursor$DefaultCursor cannot be cast to java.lang.Boolean?

Getting the error Exception in thread "main" java.lang.ClassCastException: com.rethinkdb.net.Cursor$DefaultCursor cannot be cast to java.lang.Boolean

// Login Validation
if (r.db("APSCI").table("BankAccounts").filter(row ->
   row.g("username").eq(username).and(row.g("password").eq(password))).run(conn)) {
   System.out.print("Welcome /n (username)");
}
else {
    System.out.print("No User Was Found!");
}

I'm trying to check if the username & password are valid against the user input from the scanner.

Don't know how the Java connector works, but you may find .coerceTo helpful:

r.db('APSCI').table('BankAccounts')
.getAll(username, {index: 'username'})
.filter({password: password})
.coerceTo('BOOL')

The result is true if the sequence is not empty, false otherwise.

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