I am trying to invoke stored procedure of Oracle using Oracle JDBC.
I am very new to Oracle and hence having difficulty figuring out how to invoke the SP and get the proper output.
The Stored procedure below is supposed to give me just 4 outputs with no input.
Code snippet is :
cStmt=connection.prepareCall(" {call userName.user(?)}");
cStmt.registerOutParameter(1, OracleTypes.CURSOR);
cStmt.executeUpdate();
rst = (ResultSet) cStmt.getObject(1);
while (rst.next()) {
int id = rst.getInt(1);
int Id1=rst.getInt(2);
String accoutNum=rst.getString(3);
String accountName=rst.getString(4);
System.out.println("valeus");
System.out.println(id);
System.out.println(Id1);
System.out.println(accoutNum);
System.out.println(accountName);
}
Now running this code is giving me following error:
java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'user'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:505)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:223)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:204)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1041)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1328)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3593)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3674)
at oracle.jdbc.driver.OracleCallableStatement.executeUpdate(OracleCallableStatement.java:4780)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1354)
at demo.Oracle.main(Oracle.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
I am sure there's a definite problem with the syntax. I googled a lot but I am not able to find the concrete solution..
Can someone please guide me.. JDBC jar version is 6.0
the Header of procedure is :
create or replace
procedure user is
cursor user_cursor is select * from user_master;
v_rec_user user_cursor%rowtype;