簡體   English   中英

org.postgresql.util.PSQLException:列索引超出范圍:3,列數:2

[英]org.postgresql.util.PSQLException: The column index is out of range: 3, number of columns: 2

我決定通過在其中添加使用spring security和數據庫的身份驗證來修改我的應用程序。 在我對XML中的userpassword使用普通身份驗證之前。 工作正常。

我的authentication-manager如下所示

<authentication-manager>
    <authentication-provider>
        <jdbc-user-service data-source-ref="dataSource"
        users-by-username-query="select username, password from pmc.username_password where username=?;"
        authorities-by-username-query="select a.username, b.role from pmc.username_password a, pmc.username_role b where a.username = b.username and a.username=?;" />
    </authentication-provider>
</authentication-manager>

但是當我嘗試進行身份驗證時,我遇到了異常

org.springframework.security.authentication.InternalAuthenticationServiceException: PreparedStatementCallback; SQL [select u
sername, password from pmc.username_password where username=?;]; The column index is out of range: 3, number of columns: 2.;
 nested exception is org.postgresql.util.PSQLException: The column index is out of range: 3, number of columns: 2.

XML文件中的sql語法有什么問題?

Spring Security希望用戶查詢按順序列出三列:

  1. 用戶名
  2. 密碼
  3. 已啟用(布爾值)

你沒有最后一個。 如果您的數據庫中沒有等效於“啟用”的屬性,則可以使用TRUE常量。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM