0

亲爱的,

我正在尝试使用 oracle db 对用户进行身份验证。

这是我的安全上下文弹簧配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:security="http://www.springframework.org/schema/security"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-5.2.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.3.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">



      <security:authentication-manager>
        <security:authentication-provider>
            <security:jdbc-user-service data-source-ref="dataSource"
                users-by-username-query="select user_name username, password,   'true' enabled from USERS  where user_name=?"
                authorities-by-username-query="select u.user_name username, ur.authority from USERS u, USERS_ROLES ur where u.user_id = ur.user_id and u.user_name = ?"/>
            <security:password-encoder ref="passwordEncoder" />
        </security:authentication-provider>
      </security:authentication-manager>
    
    
    

    <security:http use-expressions="true">
        <security:intercept-url pattern="/CreateOffer" access="isAuthenticated()"  />
        <security:intercept-url pattern="/docreate" access="isAuthenticated()" />
        <security:intercept-url pattern="/static/**" access="permitAll" />
        <security:intercept-url pattern="/" access="permitAll" />
        <security:intercept-url pattern="/newaccount" access="permitAll" />
        <security:intercept-url pattern="/createaccount" access="permitAll" />
        <security:intercept-url pattern="/createaccountvalidation" access="permitAll" />
        <security:intercept-url pattern="/login" access="permitAll" />
        <security:intercept-url pattern="/ShowOffer" access="permitAll" />
        <security:intercept-url pattern="/**" access="denyAll" />
        <security:form-login login-page="/login"
            login-processing-url="/login" username-parameter="custom_username"
            password-parameter="custom_password"
            authentication-failure-url="/login?error=true" />
    </security:http>

    <jee:jndi-lookup jndi-name="jdbc/myoracle"
        id="dataSource" expected-type="javax.sql.DataSource">
    </jee:jndi-lookup>
    
    <bean id="passwordEncoder"
        class="org.springframework.security.crypto.password.NoOpPasswordEncoder">
    </bean>
</beans>

用户:

Name      Null? Type          
--------- ----- ------------- 
USER_ID         NUMBER(10)    
USER_NAME       VARCHAR2(50)  
PASSWORD        VARCHAR2(100) 
ENABLED         CHAR(1)       
EMAIL           VARCHAR2(50)  

用户角色:

Name         Null? Type         
------------ ----- ------------ 
USER_ROLE_ID       NUMBER       
USER_ID            NUMBER       
AUTHORITY          VARCHAR2(45) 

我相信错误即将到来,因为它无法将 char (启用的列)转换为布尔值。我已经检查过,但找不到任何解决方案。即使我将“true”硬编码为启用的值,但它仍然无法正常工作。

Caused by: java.sql.SQLException: Fail to convert to internal representation
    at oracle.jdbc.driver.CharCommonAccessor.getBoolean(CharCommonAccessor.java:185)

完整的错误信息:

 Aug 23, 2020 12:09:12 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Server version name:   Apache Tomcat/9.0.37
    Aug 23, 2020 12:09:12 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Server built:          Jun 30 2020 20:09:49 UTC
    Aug 23, 2020 12:09:12 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Server version number: 9.0.37.0
    Aug 23, 2020 12:09:12 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: OS Name:               Windows 10
    Aug 23, 2020 12:09:12 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: OS Version:            10.0
    Aug 23, 2020 12:09:12 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Architecture:          amd64
    Aug 23, 2020 12:09:12 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Java Home:             C:\Program Files\Java\jdk-12.0.2
    Aug 23, 2020 12:09:12 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: JVM Version:           12.0.2+10
    Aug 23, 2020 12:09:12 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: JVM Vendor:            Oracle Corporation
    Aug 23, 2020 12:09:12 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: CATALINA_BASE:         D:\projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
    Aug 23, 2020 12:09:12 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: CATALINA_HOME:         C:\Program Files\Apache Software Foundation\Tomcat 9.0
    Aug 23, 2020 12:09:12 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Command line argument: -Dcatalina.base=D:\projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
    Aug 23, 2020 12:09:12 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 9.0
    Aug 23, 2020 12:09:12 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Command line argument: -Dwtp.deploy=D:\projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
    Aug 23, 2020 12:09:12 PM org.apache.catalina.startup.VersionLoggerListener log
    INFO: Command line argument: -Dfile.encoding=Cp1252
    Aug 23, 2020 12:09:12 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
    INFO: The Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path: [C:\Program Files\Java\jdk-12.0.2\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jdk-12.0.2/bin/server;C:/Program Files/Java/jdk-12.0.2/bin;c:\app\Sanjay\product\11.2.0\dbhome_1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Java\jdk-12.0.2\bin;C:\Program Files\Apache Software Foundation\apache-maven-3.6.3-bin\apache-maven-3.6.3\bin;C:\Program Files\Apache Software Foundation\apache-maven-3.6.3-bin\apache-maven-3.6.3\bin;C:\Users\Sanjay\AppData\Local\Microsoft\WindowsApps;;C:\WINDOWS\system32;;.]
    Aug 23, 2020 12:09:13 PM org.apache.coyote.AbstractProtocol init
    INFO: Initializing ProtocolHandler ["http-nio-8686"]
    Aug 23, 2020 12:09:13 PM org.apache.catalina.startup.Catalina load
    INFO: Server initialization in [782] milliseconds
    Aug 23, 2020 12:09:13 PM org.apache.catalina.core.StandardService startInternal
    INFO: Starting service [Catalina]
    Aug 23, 2020 12:09:13 PM org.apache.catalina.core.StandardEngine startInternal
    INFO: Starting Servlet engine: [Apache Tomcat/9.0.37]
    Aug 23, 2020 12:09:13 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
    WARNING: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [153] milliseconds.
    Aug 23, 2020 12:09:15 PM org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory getObjectInstance
    WARNING: Name = myoracle Property maxActive is not used in DBCP2, use maxTotal instead. maxTotal default value is 8. You have set value of "20" for "maxActive" property, which is being ignored.
    Aug 23, 2020 12:09:15 PM org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory getObjectInstance
    WARNING: Name = myoracle Property maxWait is not used in DBCP2 , use maxWaitMillis instead. maxWaitMillis default value is -1. You have set value of "-1" for "maxWait" property, which is being ignored.
    Aug 23, 2020 12:09:15 PM org.apache.jasper.servlet.TldScanner scanJars
    INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
    Aug 23, 2020 12:09:15 PM org.apache.catalina.core.ApplicationContext log
    INFO: No Spring WebApplicationInitializer types detected on classpath
    Aug 23, 2020 12:09:15 PM org.apache.catalina.core.ApplicationContext log
    INFO: Initializing Spring DispatcherServlet 'offer'
    Aug 23, 2020 12:09:15 PM org.springframework.web.servlet.FrameworkServlet initServletBean
    INFO: Initializing Servlet 'offer'
    Aug 23, 2020 12:09:15 PM org.springframework.security.core.SpringSecurityCoreVersion performVersionChecks
    INFO: You are running with Spring Security Core 5.2.6.RELEASE
    Aug 23, 2020 12:09:15 PM org.springframework.security.config.SecurityNamespaceHandler <init>
    INFO: Spring Security 'config' module version is 5.2.6.RELEASE
    Aug 23, 2020 12:09:15 PM org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser parseInterceptUrlsForFilterInvocationRequestMap
    INFO: Creating access control expression attribute 'isAuthenticated()' for /CreateOffer
    Aug 23, 2020 12:09:15 PM org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser parseInterceptUrlsForFilterInvocationRequestMap
    INFO: Creating access control expression attribute 'isAuthenticated()' for /docreate
    Aug 23, 2020 12:09:15 PM org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser parseInterceptUrlsForFilterInvocationRequestMap
    INFO: Creating access control expression attribute 'permitAll' for /static/**
    Aug 23, 2020 12:09:15 PM org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser parseInterceptUrlsForFilterInvocationRequestMap
    INFO: Creating access control expression attribute 'permitAll' for /
    Aug 23, 2020 12:09:15 PM org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser parseInterceptUrlsForFilterInvocationRequestMap
    INFO: Creating access control expression attribute 'permitAll' for /newaccount
    Aug 23, 2020 12:09:15 PM org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser parseInterceptUrlsForFilterInvocationRequestMap
    INFO: Creating access control expression attribute 'permitAll' for /createaccount
    Aug 23, 2020 12:09:15 PM org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser parseInterceptUrlsForFilterInvocationRequestMap
    INFO: Creating access control expression attribute 'permitAll' for /createaccountvalidation
    Aug 23, 2020 12:09:15 PM org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser parseInterceptUrlsForFilterInvocationRequestMap
    INFO: Creating access control expression attribute 'permitAll' for /login
    Aug 23, 2020 12:09:15 PM org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser parseInterceptUrlsForFilterInvocationRequestMap
    INFO: Creating access control expression attribute 'permitAll' for /ShowOffer
    Aug 23, 2020 12:09:16 PM org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser parseInterceptUrlsForFilterInvocationRequestMap
    INFO: Creating access control expression attribute 'denyAll' for /**
    Aug 23, 2020 12:09:16 PM org.springframework.security.config.http.HttpSecurityBeanDefinitionParser checkFilterChainOrder
    INFO: Checking sorted filter chain: [Root bean: class [org.springframework.security.web.context.SecurityContextPersistenceFilter]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 200, Root bean: class [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 400, Root bean: class [org.springframework.security.web.header.HeaderWriterFilter]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 500, Root bean: class [org.springframework.security.web.csrf.CsrfFilter]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 700, <org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0>, order = 1200, Root bean: class [org.springframework.security.web.savedrequest.RequestCacheAwareFilter]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 1900, Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.security.config.http.HttpConfigurationBuilder$SecurityContextHolderAwareRequestFilterBeanFactory#0; factoryMethodName=getBean; initMethodName=null; destroyMethodName=null, order = 2000, Root bean: class [org.springframework.security.web.authentication.AnonymousAuthenticationFilter]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2300, Root bean: class [org.springframework.security.web.session.SessionManagementFilter]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2400, Root bean: class [org.springframework.security.web.access.ExceptionTranslationFilter]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null, order = 2500, <org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0>, order = 2600]
    Aug 23, 2020 12:09:16 PM org.hibernate.validator.internal.util.Version <clinit>
    INFO: HV000001: Hibernate Validator 6.1.5.Final
    Aug 23, 2020 12:09:17 PM org.springframework.security.provisioning.JdbcUserDetailsManager initDao
    INFO: No authentication manager set. Reauthentication of users when changing passwords will not be performed.
    Aug 23, 2020 12:09:17 PM org.springframework.security.web.DefaultSecurityFilterChain <init>
    INFO: Creating filter chain: any request, [org.springframework.security.web.context.SecurityContextPersistenceFilter@299c86f0, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@4fbed6fc, org.springframework.security.web.header.HeaderWriterFilter@1b1d93e9, org.springframework.security.web.csrf.CsrfFilter@129b0ed, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@4ccf1d3e, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@75ff2b6d, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@20a7ce0, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@4ee80a94, org.springframework.security.web.session.SessionManagementFilter@7afac89a, org.springframework.security.web.access.ExceptionTranslationFilter@76d220eb, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@276eafad]
    Aug 23, 2020 12:09:17 PM org.springframework.security.config.http.DefaultFilterChainValidator checkLoginPageIsntProtected
    INFO: Checking whether login URL '/login' is accessible with your configuration
    Aug 23, 2020 12:09:17 PM org.springframework.web.servlet.FrameworkServlet initServletBean
    INFO: Completed initialization in 2225 ms
    Aug 23, 2020 12:09:17 PM org.apache.coyote.AbstractProtocol start
    INFO: Starting ProtocolHandler ["http-nio-8686"]
    Aug 23, 2020 12:09:17 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in [4343] milliseconds
    Aug 23, 2020 12:09:25 PM org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter doFilter
    SEVERE: An internal error occurred while trying to authenticate the user.
    org.springframework.security.authentication.InternalAuthenticationServiceException: PreparedStatementCallback; uncategorized SQLException for SQL [select user_name username, password, 'true' enabled from USERS where user_name=?]; SQL state [99999]; error code [17059]; Fail to convert to internal representation; nested exception is java.sql.SQLException: Fail to convert to internal representation
        at org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:123)
        at org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:144)
        at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:175)
        at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:195)
        at org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:95)
        at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:212)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
        at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:141)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
        at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92)
        at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
        at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
        at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
        at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1589)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.base/java.lang.Thread.run(Thread.java:835)
    Caused by: org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [select user_name username, password, 'true' enabled from USERS where user_name=?]; SQL state [99999]; error code [17059]; Fail to convert to internal representation; nested exception is java.sql.SQLException: Fail to convert to internal representation
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:89)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
        at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1443)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:633)
        at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:669)
        at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:700)
        at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:712)
        at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:763)
        at org.springframework.security.provisioning.JdbcUserDetailsManager.loadUsersByUsername(JdbcUserDetailsManager.java:150)
        at org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl.loadUserByUsername(JdbcDaoImpl.java:181)
        at org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:108)
        ... 41 more
    Caused by: java.sql.SQLException: Fail to convert to internal representation
        at oracle.jdbc.driver.CharCommonAccessor.getBoolean(CharCommonAccessor.java:185)
        at oracle.jdbc.driver.T4CCharAccessor.getBoolean(T4CCharAccessor.java:697)
        at oracle.jdbc.driver.OracleResultSetImpl.getBoolean(OracleResultSetImpl.java:640)
        at org.apache.tomcat.dbcp.dbcp2.DelegatingResultSet.getBoolean(DelegatingResultSet.java:358)
        at org.apache.tomcat.dbcp.dbcp2.DelegatingResultSet.getBoolean(DelegatingResultSet.java:358)
        at org.springframework.security.provisioning.JdbcUserDetailsManager.lambda$loadUsersByUsername$0(JdbcUserDetailsManager.java:155)
        at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:94)
        at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:61)
        at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:679)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:617)
        ... 48 more

在此先感谢您的帮助。

4

1 回答 1

0

我使用 char 作为启用的数据类型,并且 char 被转换为 java.lang.String 或 oracle.sql.CHAR。

我将其更改为数字,因为数字可以转换为布尔值并且效果很好。

请使用以下链接获取完整参考:
https ://docs.oracle.com/cd/E11882_01/java.112/e16548/apxref.htm#JJDBC28906

于 2020-08-23T10:41:02.537 回答