i am trying to execute stored procedure.
Code:
@Repository
public class PaymentDaoImpl implements PaymentDao {
@Autowired
private SessionFactory sessionFactory;
private Session session;
private Transaction trans;
SimpleDateFormat smd = new SimpleDateFormat("dd-MMM-yyyy");
Date jdate = new Date();
String s =smd.format( new java.sql.Date(jdate.getTime()));
Date utilDate = new Date();
java.sql.Date sdate = new java.sql.Date(utilDate.getTime());
public void savePayments(PaymentParams paymentParams) {
try {
session = sessionFactory.openSession();
trans = session.beginTransaction();
System.out.println("date format");
System.out.println(sdate);
StoredProcedureQuery query = session.createStoredProcedureQuery(" PROC_INS_RMIS_BNK_VCHER_TABLE");
query.registerStoredProcedureParameter("P_BUD_YEAR",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_DISTRICT_CODE",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_TRAN_NDATE",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_TRAN_EDATE",Date.class, ParameterMode.IN); //date
query.registerStoredProcedureParameter("P_BANK_CODE",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_DEPOSIT_BANK_CODE",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_ECONOMIC_CODE5",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_PO_CODE",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_AMOUNT",Number.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_PAN",Number.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_PAYEE_NAME",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_PAYEE_ADD",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_PHONE_NO",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_TAX_YEAR",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_PAYMENT_TYPE",char.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_CHEQUE_DRAFT_NO",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_DATETIME",Date.class, ParameterMode.IN); //date
query.registerStoredProcedureParameter("P_CREATED_BY",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_TAX_FLAG",char.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_CLEARANCE_EDATE",Date.class, ParameterMode.IN); //date
query.registerStoredProcedureParameter("P_CLEARANCE_NDATE",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_VOUCHER_NO",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_CHEQUE_TYPE",char.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_CHE_DRA_ISSUE_BANK",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_VOUCHER_STATUS",char.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_RECORD_LOCK_FLAG",char.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_VOUCHER_DATE",Date.class, ParameterMode.IN); //date
query.registerStoredProcedureParameter("P_ADJUST_FLAG",char.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_VOUCHER_NDATE",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_DEPOSIT_SLIP_NO",Number.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_COUNTER_CODE",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_UPDATE_DATETIME",Date.class, ParameterMode.IN); //date
query.registerStoredProcedureParameter("P_UPDATE_BY",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_PO_AMDANI_FLAG",char.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_DOLLAR_AMOUNT",Number.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_UPDATE_NDATE",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_DEPOSIT_SLIP_AUTO",char.class, ParameterMode.IN);
query.registerStoredProcedureParameter("P_TRAN_BUD_YEAR",String.class, ParameterMode.IN);
query.registerStoredProcedureParameter("p_error_code",String.class, ParameterMode.IN);
query.setParameter("P_BUD_YEAR","2071/72");
query.setParameter("P_DISTRICT_CODE","42");
query.setParameter("P_TRAN_NDATE","2071/72");
query.setParameter("P_TRAN_EDATE",sdate);
query.setParameter("P_BANK_CODE","11009001");
query.setParameter("P_DEPOSIT_BANK_CODE","11009001");
query.setParameter("P_PO_CODE","28-204-02");
query.setParameter("P_ECONOMIC_CODE5","14224");
query.setParameter("P_AMOUNT",132);
query.setParameter("P_PAN",0);
query.setParameter("P_PAYEE_NAME","12345");
query.setParameter("P_PAYEE_ADD","Patan");
query.setParameter("P_PHONE_NO","553658");
query.setParameter("P_TAX_YEAR","2071/72");
query.setParameter("P_PAYMENT_TYPE",'A');
query.setParameter("P_CHEQUE_DRAFT_NO","NULL");
query.setParameter("P_DATETIME",sdate);
query.setParameter("P_CREATED_BY","psc");
query.setParameter("P_TAX_FLAG",'N');
query.setParameter("P_CLEARANCE_EDATE",sdate);
query.setParameter("P_CLEARANCE_NDATE","2071-04-01");
query.setParameter("P_VOUCHER_NO","v_voucher_no");
query.setParameter("P_CHEQUE_TYPE",'A');
query.setParameter("P_CHE_DRA_ISSUE_BANK","NULL");
query.setParameter("P_VOUCHER_STATUS",'T');
query.setParameter("P_RECORD_LOCK_FLAG",'Y');
query.setParameter("P_VOUCHER_DATE",sdate);
query.setParameter("P_ADJUST_FLAG",'N');
query.setParameter("P_VOUCHER_NDATE","2071-04-01");
query.setParameter("P_DEPOSIT_SLIP_NO",25764132);
query.setParameter("P_COUNTER_CODE","P3");
query.setParameter("P_UPDATE_DATETIME",sdate);
query.setParameter("P_UPDATE_BY","psc");
query.setParameter("P_PO_AMDANI_FLAG",'Y');
query.setParameter("P_DOLLAR_AMOUNT",0);
query.setParameter("P_UPDATE_NDATE","2073-04-03");
query.setParameter("P_DEPOSIT_SLIP_AUTO",'N');
query.setParameter("P_TRAN_BUD_YEAR","2073/74");
query.setParameter("p_error_code","v_error_code");
query.execute();
String error = (String) query.getOutputParameterValue("p_error_code");
System.out.println(error);
System.out.println("executed");
}catch (Exception e){
e.printStackTrace();
}
}
}
the error it throws :-
Code:
javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: Error calling CallableStatement.getMoreResults
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:147)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155)
at org.hibernate.procedure.internal.ProcedureCallImpl.execute(ProcedureCallImpl.java:653)
at com.infodev.dao.PaymentDaoImpl.savePayments(PaymentDaoImpl.java:121)
at com.infodev.services.PaymentServicesImpl.savePayment(PaymentServicesImpl.java:19)
at com.infodev.controls.PaymentController.savePayment(PaymentController.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.hibernate.exception.SQLGrammarException: Error calling CallableStatement.getMoreResults
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:106)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
at org.hibernate.result.internal.OutputsImpl.convert(OutputsImpl.java:78)
at org.hibernate.result.internal.OutputsImpl.<init>(OutputsImpl.java:55)
at org.hibernate.procedure.internal.ProcedureOutputsImpl.<init>(ProcedureOutputsImpl.java:32)
at org.hibernate.procedure.internal.ProcedureCallImpl.buildOutputs(ProcedureCallImpl.java:453)
at org.hibernate.procedure.internal.ProcedureCallImpl.getOutputs(ProcedureCallImpl.java:404)
at org.hibernate.procedure.internal.ProcedureCallImpl.outputs(ProcedureCallImpl.java:663)
at org.hibernate.procedure.internal.ProcedureCallImpl.execute(ProcedureCallImpl.java:646)
... 42 more
Caused by: java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'PROC_INS_RMIS_BNK_VCHER_TABLE'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'PROC_INS_RMIS_BNK_VCHER_TABLE'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'PROC_INS_RMIS_BNK_VCHER_TABLE'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'PROC_INS_RMIS_BNK_VCHER_TABLE'
ORA-06550: line 1, column 7:
1. am i calling stored procedure correctly?
2. am i passing the date parameter correctly?