错误:org.postgresql.util.PSQLException:列索引超出范围:3,列数:2

时间:2015-08-20 06:53:12

标签: java spring postgresql spring-mvc jdbc

我正在尝试使用Spring-Mvc通过引用this url来简单登录应用程序。但在这样做的过程中,我遇到了以下错误:

  

org.springframework.security.authentication.InternalAuthenticationServiceException:PreparedStatementCallback; SQL [选择用户名,用户密码来自用户名=?];列索引超出范围:3,列数:2。嵌套异常是org.postgresql.util.PSQLException:列索引超出范围:3,列数:2。       在org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:110)       在org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:132)       在org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:156)       在org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:177)       在org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:94)       在org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:211)       在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342)       在org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)       在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342)       在org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)       在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)       在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342)       在org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)       在org.springframework.security.web.FilterChainProxy $ VirtualFilterChain.doFilter(FilterChainProxy.java:342)       在org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)       在org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)       在org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)       在org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)       在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)       在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)       在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)       在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)       在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)       在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)       在org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)       在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)       在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)       在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)       at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:611)       在org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.doRun(AprEndpoint.java:2466)       在org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.run(AprEndpoint.java:2455)       at java.util.concurrent.ThreadPoolExecutor $ Worker.runTask(ThreadPoolExecutor.java:886)       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:908)       at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)       在java.lang.Thread.run(Thread.java:662)

我在程序中所做的唯一更改是更改spring-security文件中的查询,这里提到:

原:

<authentication-provider>
       <jdbc-user-service data-source-ref="myDataSource"
           users-by-username-query="select username,password from users where username=?"
           authorities-by-username-query="select username, role from users where username=?" />
   </authentication-provider>

改变:

<authentication-provider>
       <jdbc-user-service data-source-ref="myDataSource"
           users-by-username-query="select username,password,enabled from users where username=?"
           authorities-by-username-query="select username, role from users where username=?" />
   </authentication-provider>

我的users表中没有任何启用的字段。所以我删除了它。我正在使用PostgreSQL数据库。 url中给出的示例是使用oracle / mysql数据库。

在oracle中“启用”任何内置字段或关键字?如果是,那么在PostgreSQL数据库中它的替代品是什么。

0 个答案:

没有答案