Java调oracle函数,返回游标,当cstm.execute()时,报空指针的错误!
java.sql.SQLException:execute,Exception=nullatweblogic.jdbc.wrapper.JDBCWrapperImpl.i...
java.sql.SQLException: execute, Exception = null
at weblogic.jdbc.wrapper.JDBCWrapperImpl.invocationExceptionHandler(JDBCWrapperImpl.java:157)
at weblogic.jdbc.wrapper.PreparedStatement.execute(PreparedStatement.java:115)
at gdcg.emdc.ptcmsHis.dao.impl.CPMSHistoryDaoImpl.getPDHZList(CPMSHistoryDaoImpl.java:631)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
at com.geok.framework.dao.impl.FrameworkAopLogger.bussinessAround(Unknown Source)
at sun.reflect.GeneratedMethodAccessor196.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
代码:
Connection conn = null;
CallableStatement cstm = null;
try {
conn=super.jdbcTemplate.getDataSource().getConnection();
cstm = conn.prepareCall("{? = func_test9999()}");
cstm.registerOutParameter(1, oracle.jdbc.OracleTypes.CURSOR);
cstm.execute();
ResultSet rs = (ResultSet) cstm.getObject(1);
List<Map> list = new ArrayList<Map>();
if(rs.next()){
System.out.println(rs.getString(3));
return list;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} 展开
at weblogic.jdbc.wrapper.JDBCWrapperImpl.invocationExceptionHandler(JDBCWrapperImpl.java:157)
at weblogic.jdbc.wrapper.PreparedStatement.execute(PreparedStatement.java:115)
at gdcg.emdc.ptcmsHis.dao.impl.CPMSHistoryDaoImpl.getPDHZList(CPMSHistoryDaoImpl.java:631)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
at com.geok.framework.dao.impl.FrameworkAopLogger.bussinessAround(Unknown Source)
at sun.reflect.GeneratedMethodAccessor196.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
代码:
Connection conn = null;
CallableStatement cstm = null;
try {
conn=super.jdbcTemplate.getDataSource().getConnection();
cstm = conn.prepareCall("{? = func_test9999()}");
cstm.registerOutParameter(1, oracle.jdbc.OracleTypes.CURSOR);
cstm.execute();
ResultSet rs = (ResultSet) cstm.getObject(1);
List<Map> list = new ArrayList<Map>();
if(rs.next()){
System.out.println(rs.getString(3));
return list;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} 展开
1个回答
2016-08-05 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
1.通过存储过程的出参,将“当前用户:user_id”连接串返回;
比如:
假设你的过程叫,prc_test,在参数列表中增加出参。
create or replace procedure prc_test(入参 in 类型, 出参 out 类型) is
begin
-- 逻辑实现
end;
出参就是你要把内容放进去,用来传值的变量。
2.在过程中保存一张临时表,然后在java中查出这个临时表中保存的数据。
定义临时表table_temp
在过程中
insert into table_temp(msg) values ('当前用户:' || user_id);
比如:
假设你的过程叫,prc_test,在参数列表中增加出参。
create or replace procedure prc_test(入参 in 类型, 出参 out 类型) is
begin
-- 逻辑实现
end;
出参就是你要把内容放进去,用来传值的变量。
2.在过程中保存一张临时表,然后在java中查出这个临时表中保存的数据。
定义临时表table_temp
在过程中
insert into table_temp(msg) values ('当前用户:' || user_id);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询