I get this error when I try reading from an oracle database:
java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
However, I've tested the query with same credentials on a client and it works. What could be wrong.
Find below my connection setup:
@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);
}
and my configuration:
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
and the query:
@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();
}