游标$ DefaultCursor无法强制转换为java.lang.Boolean?

问题描述 投票:1回答:1

得到错误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!");
}

我正在尝试检查用户名和密码是否对扫描仪的用户输入有效。

java rethinkdb
1个回答
0
投票

不知道Java连接器是如何工作的,但是你可能会发现.coerceTo很有帮助:

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

如果序列不为空,则结果为true,否则为false

© www.soinside.com 2019 - 2024. All rights reserved.