Calling procedures with same name with different arguments from java
hi,
I have a package and a package body as follows in oracle database
PACKAGE TEST
IS
procedure addUser(
id NUMBER,
userName VARCHAR2);
procedure addUser(
id NUMBER,
userName VARCHAR2,
sex varchar2,
TEST nvarchar2);
procedure addUser(
id NUMBER,
userName VARCHAR2,
sex varchar2,
age NUMBER
);
END;
PACKAGE BODY TEST
IS
PROCEDURE addUser(
id NUMBER,
userName VARCHAR2)
IS
a NUMBER;
BEGIN
a := 150;
END;
PROCEDURE addUser(
id NUMBER,
userName VARCHAR2,
sex varchar2,
TEST nvarchar2)
IS
a NUMBER;
BEGIN
a := 150;
END;
PROCEDURE addUser(
id NUMBER,
userName VARCHAR2,
sex varchar2,
age NUMBER)
IS
a NUMBER;
BEGIN
a := 150;
END;
-- Enter further code below as specified in the Package spec.
END;
when i execute this by using the following java program it gives the following error. I used classes12.jar for creating the
import java.sql.*;
public class Test {
public static void main(String args[]){
try {
Class.forName("oracle.jdbc.OracleDriver");
String sourceURL = "jdbc:oracle:thin:@192.168.0.180:1521:DB01";
Connection connection = DriverManager.getConnection(sourceURL,
"MUBASHER_OMS", "password");
String spName = "{call TEST.addUser(?,?,?,?)}";
CallableStatement pstmtUpdate = connection.prepareCall(spName);
pstmtUpdate.setNull(1,Types.VARCHAR);
pstmtUpdate.setNull(2,Types.VARCHAR);
pstmtUpdate.setNull(3,Types.NUMERIC);
pstmtUpdate.setString(4,"dd");
pstmtUpdate.execute();
} catch (ClassNotFoundException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (SQLException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
}
Error given after executing above program is ---
java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00307: too many declarations of 'ADDUSER' match this call
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:215)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1130)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1280)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3469)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3575)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:5261)
at Test.main(Test.java:44)
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:585)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
If some one has ever troubled with oracle procedure calling from java which is procedure overloaded please help me on this... i have searched everywhere to find a solution for this.