OracleTypes.ARRAY
多次调用带有输入参数的Oracle存储过程时,会出现以下错误: -
org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{call EMP_SCHEMA.GET_EMPLOYEE_LIST(?, ?)}]; SQL state [72000]; error code [1000]; ORA-01000: maximum open cursors exceeded; nested exception is java.sql.SQLException: ORA-01000: maximum open cursors exceeded at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84) ~[spring-jdbc-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) ~[spring-jdbc-4.1.6.RELEASE.jar:4.1.6.RELEASE]
JDBC模板配置是: -
存储过程类: -
public class GetEmployees extends StoredProcedure { public GetEmployees(JdbcTemplate jdbcTemplate) { super(jdbcTemplate, "EMP_SCHEMA.GET_EMPLOYEE_LIST"); declareParameter(new SqlParameter("p_emp_id_list", OracleTypes.ARRAY, "TBL_EMP_ID")); declareParameter(new SqlOutParameter(CURSOR, OracleTypes.CURSOR, new EmployeeDataRowMapper())); compile(); } public ListofIds(Set employeeIds) { Map params = new HashMap<>(); params.put("p_emp_id_list", new OracleArraySqlTypeValue(employeeIds)); final Map result = execute(params); return (List ) result.get(CURSOR); } }
Oracle SqlTypeValue: -
public class OracleArraySqlTypeValue extends AbstractSqlTypeValue { private final String[][] employeeIds; public OracleArraySqlTypeValue(String[][] employeeIds) { this.employeeIds = employeeIds; } @Override protected Object createTypeValue(Connection connection, int sqlType, String typeName) throws SQLException { ArrayDescriptor arrayDescriptor = new ArrayDescriptor(typeName, connection); return new ARRAY(arrayDescriptor, connection, employeeIds); } }
而不是CommonsDbcpNativeJdbcExtractor
尝试OracleJdbc4NativeJdbcExtractor
过.但仍然存在错误.
基本上堆包含许多未闭合的Statement
对象.知道为什么春天没有关闭资源?
环境: - Java 1.8,Spring 4.1.6,Tomcat 7.