我正在尝试使用NamedParameterJdbcTemplate从oracle存储过程中检索数据,下面是我正在使用的代码片段。
ApplicationContext context = new ClassPathXmlApplicationContext("/bean.xml");
DAOImpl dAOImpl = (DAOImpl) context.getBean("daoImpl");
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("param", "value1");
String query = "{ <SCHEMA_NAME>.<package_name>.<stored_proc>(:param) }";
List<String[]> arrList = dAOImpl.getDaoTmplt().execute(query, paramMap,new PreparedStatementCallback<List<String[]>>(){
@Override
public List<String[]> doInPreparedStatement(PreparedStatement ps)
throws SQLException, DataAccessException {
ResultSet rs = ps.executeQuery();
List<String[]> arrList = new ArrayList<String[]>();
while (rs.next()) {
String[] strArr = new String[4];
strArr[0] = rs.getString("COLUMN_A");
strArr[1] = rs.getString("COLUMN_B");
strArr[2] = rs.getString("COLUMN_C");
strArr[3] = rs.getString("COLUMN_D");
arrList.add(strArr);
}
rs.close();
return arrList;
}
});
我得到以下提到的异常:
PreparedStatementCallback; bad SQL grammar [{ CALL <SCHEMA_NAME>.<package_name>.<stored_proc>(?) }]; nested exception is java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00221: '<stored_proc>' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
当我在TOAD中运行以下查询时,它返回数据 -
select <SCHEMA_NAME>.<package_name>.<stored_proc>('value1') from dual;
如果我某处出错,有人可以纠正我吗?
提前致谢!
答案 0 :(得分:0)
尝试使用execute execute with executeQuery
来调用SPps.execute();
ResultSet rs = ps.getResultSet();