当前位置: 首页 > 知识库问答 >
问题:

无法获取JDBC连接;嵌套异常是java.sql.sqlexception:ORA-28040:Spring批处理中没有匹配的身份验证协议

储仲渊
2023-03-14

我正在使用Spring批处理并连接到Oracle12c实例。

org.springframework.JDBC.CanNotGetJdbcConnectionException:无法获取JDBC连接;嵌套异常是java.sql.sqlexception:ORA-28040:没有匹配的身份验证协议

org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: ORA-28040: No matching authentication protocol

    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:619)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:684)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:716)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:726)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:781)
    at org.springframework.batch.core.repository.dao.JdbcJobInstanceDao.getJobInstance(JdbcJobInstanceDao.java:145)
    at org.springframework.batch.core.repository.support.SimpleJobRepository.getLastJobExecution(SimpleJobRepository.java:284)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:280)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy1.getLastJobExecution(Unknown Source)
    at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:98)
    at CustomerFileGenerationMain.main(CustomerFileGenerationMain.java:28)
Caused by: java.sql.SQLException: ORA-28040: No matching authentication protocol
<bean id="DataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
    <property name="username" value="MY_OWNER"/>
    <property name="url" value="jdbc:oracle:thin:@//localhost:1527/myCloud" />
    <property name="password" value="" />
</bean>

<bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />

<bean id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean" >
    <property name="dataSource" ref="DataSource" />
    <property name="transactionManager" ref="transactionManager" />
    <property name="databaseType" value="ORACLE" />
</bean>
<dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
        </dependency>
<dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc7</artifactId>
            <version>12.1.0.1</version>
        </dependency>
@Bean(name = "DataSource")
    public DataSource batchDataSource() throws IOException {    
        OracleDataSource ds = null;
        MCUserInfoFactory userInfoFactory = new MCUserInfoFactory();
        try {
            MCUserInfo userInfo = userInfoFactory.getMCUserInfo(XXXXLabel);
            if (userInfo != null) {
                ds = getDataSource(userInfo, edsurl);
            }
        } catch (Exception e) {

        }
        return ds;
    }

我使用的是以下版本-

/:/oracle/home $ sqlplus / as sysdba
-bash: sqlplus: command not found
/:/oracle/home $ . ~/.profile
/:/oracle/home $ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Thu Jun 28 01:56:56 2018

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options

共有1个答案

牟慎之
2023-03-14

检查驱动程序文件(.jar)版本和您使用的ORACLE db版本是否兼容,这通常会导致此问题。

 类似资料: