【问题标题】:ORA-00942: table or view does not exist even though it doesORA-00942: 表或视图不存在,即使它存在
【发布时间】:2018-07-25 14:26:17
【问题描述】:

当我尝试从 oracle 数据库中读取时出现此错误:

java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

但是,我已经在客户端上使用相同的凭据测试了查询,并且它可以正常工作。可能有什么问题。

在下面找到我的连接设置:

@Bean(name="eJDBCDatasource")
@ConfigurationProperties(prefix = "spring.datasourceexample")
public DataSource eJDBCDatasource(){
    return DataSourceBuilder.create().build();
}

@Bean(name="exampleNmpJDBCTemplate")
public NamedParameterJdbcTemplate exampleNmpJDBCTemplate(@Qualifier("eJDBCDatasource") DataSource eJDBCDatasource){
    return new NamedParameterJdbcTemplate(eJDBCDatasource);
}

和我的配置:

spring.datasourceexample.url=jdbc:oracle:thin:@//X.X.X.X:1521/EXDB
spring.datasourceexample.username=read
spring.datasourceexample.password=readp
spring.datasourceexample.driverClassName=oracle.jdbc.driver.OracleDriver
spring.datasourceexample.max-active=50
spring.datasourceexample.initial-size=20
spring.datasourceexample.max-idle=5
spring.datasourceexample.min-idle=1
spring.datasourceexample.test-while-idle=true
spring.datasourceexample.testOnBorrow=false
spring.datasourceexample.validationQuery=SELECT 1
spring.datasourceexample.time-between-eviction-runs-millis=5000 
spring.datasourceexample.min-evictable-idle-time-millis=60000
spring.datasourceexample.unreturnedConnectionTimeout=30000
spring.datasourceexample.debugUnreturnedConnectionStackTraces=true
spring.datasourceexample.maxIdleTimeExcessConnections=300

和查询:

@Autowired
NamedParameterJdbcTemplate exampleNmpJDBCTemplate;

public Boolean isExample(String Id) {

    SqlParameterSource param = new MapSqlParameterSource()
            .addValue("id", Id);
    List result = (List) exampleNmpJDBCTemplate.queryForList(this.examplesearchQuery, param);
    return !result.isEmpty();
}

【问题讨论】:

  • 甲骨文不会说谎。如果你在 sqlplus 中使用相同的用户名登录,会发生什么?
  • 它有效。我已经解决了这个问题。谢谢?????????

标签: java oracle spring-boot jdbc


【解决方案1】:

解决了问题 我在应用程序中有其他数据源连接。因此我需要添加 @Qualifier 注释。

@Autowired
@Qualifier("exampleNmpJDBCTemplate")
NamedParameterJdbcTemplate exampleNmpJDBCTemplate;

【讨论】:

    猜你喜欢
    • 2019-01-22
    • 2015-11-09
    • 2011-12-10
    • 2015-01-30
    • 2016-08-23
    • 2020-10-16
    • 2018-02-05
    • 1970-01-01
    相关资源
    最近更新 更多