I'm trying to get some data from Oracle DB using Spring JDBCTemplate:
String query = "SELECT * FROM snow.ar_incident WHERE ROWNUM < 10";
Map<String, List<Attachment>> map = jdbcTemplate.query(query, new ResultSetExtractor<Map<String, List<Attachment>>>() {
@Override
public Map<String, List<Attachment>> extractData(ResultSet rs) throws SQLException, DataAccessException {
Map<String, List<Attachment>> map = new HashMap<>();
//Mapping results to map
return map;
}
});
But I'm always getting an exception only for ar_incidient
table:
Caused by: org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [SELECT * from snow.ar_incident WHERE ROWNUM < 10]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
This code works perfectly fine for other tables but not for this one. I also tried to get data from this table using core Java sql connection:
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection(connString, user, pass);
Statement stmt=con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * from snow.ar_incident WHERE ROWNUM < 10");
And it worked without a problem, same when I run the query in SQL Developer. I have checked many times connection details for the both solutions and they are identical. Why can't I access ar_incident
table using JDBCTemplate?
Please check if grants are there and if you need to prefix table name with schema.table_name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With