简体   繁体   中英

I'm getting this error pls 00103 when using netbeans

I have established a connection to my oracle database with username system

The connection is successfull and i'm able to do all my basic sql operations like insert , update,delete... but I'm unable to execute my stored procedures. While i'm trying to call my stored procedure from netbeans i'm getting some errors . Please help me in solving this issue.

netbeans buttonPerformed code

    int eid = Integer.parseInt(eidtf.getText());
    String ename = enametf.getText();
    String dob = dobtf.getText();

    String sex = male.getText();
    if (female.isEnabled() == true) {
        sex = female.getText();
    }

    String designation = destf.getText();
    int basic = Integer.parseInt(basictf.getText());

    //String sql = "exec calc(" +eid +","+ basic +",'"+ ename +"','"+ sex +"','"+ dob +"','"+ designation +"')";

    try {
        CallableStatement cs = con.prepareCall("{call calc(? ? ? ? ? ?)}");

        cs.setInt(2, 50);
        cs.setInt(1, 126);
        cs.setString(3, ename);
        cs.setString(4, sex);
        cs.setString(5, dob);
        cs.setString(6, designation);

        cs.execute();

        JOptionPane.showMessageDialog(this, "Insertion has been done successfully!!!");
    } catch (SQLException ex) {
        JOptionPane.showMessageDialog(this, "Error: " + ex.getMessage() + "\nCause: " + ex.getCause() + "\nError Code: " + ex.getErrorCode() + "\nStack: " + ex.getClass());
    }

Table and Procedure below:

create table emp_payroll
(eid number(4) primary key,
ename varchar(20),
dob date,
sex char(1),
designation varchar(20),
basic number(5,2),
da number(5,2),
hra number(5,2),
pf number(5,2),
mc number(5,2),
gross number(5,2),
ded number(5,2),
net_pay number(5,2)
);

create or replace procedure calc
(x_eid in emp_payroll.eid%type :=123,
x_basic in emp_payroll.basic%type,
x_name in emp_payroll.ename%type,
x_sex in emp_payroll.ename%type,
x_dob in emp_payroll.ename%type,
x_des in emp_payroll.ename%type
)
as

x_da  emp_payroll.basic%type;
x_hra  emp_payroll.basic%type;
x_pf  emp_payroll.basic%type;
x_mc  emp_payroll.basic%type;
x_gross  emp_payroll.basic%type;
x_ded  emp_payroll.basic%type;
x_net_pay  emp_payroll.basic%type;

begin

    x_da:=.6* x_basic;
    x_hra:=.6* x_basic;
    x_pf:=.6* x_basic;
    x_mc:=.6* x_basic;
    x_gross:=x_basic+x_da+x_hra;
    x_ded:=x_pf+x_mc;
    x_net_pay:=x_gross-x_ded;
  insert into emp_payroll values(x_eid,x_name,x_dob,x_sex,x_des,x_basic,x_da,x_hra,x_pf,x_mc,x_gross,x_ded,x_net_pay) ;

end calc;
/

When i run the below command in sqlplus:

exec calc(123,50,'Har','m','12-apr-2000','student');

I'm getting the intended o/p. But when i do the same in netbeans i'm not getting the intended op but some error.

Errors:This is the error i'm getting:
错误消息我在这里进入netbeans

Quick help is appreciated. Thanks in advance...

The javadoc of CallableStatement says:

The interface used to execute SQL stored procedures. The JDBC API provides a stored procedure SQL escape syntax that allows stored procedures to be called in a standard way for all RDBMSs. This escape syntax has one form that includes a result parameter and one that does not. If used, the result parameter must be registered as an OUT parameter. The other parameters can be used for input, output or both. Parameters are referred to sequentially, by number, with the first parameter being 1.

 {?= call <procedure-name>[(<arg1>,<arg2>, ...)]} {call <procedure-name>[(<arg1>,<arg2>, ...)]} 

As you can see, the arguments are separated by commas, same as pretty much any syntax for passing parameters to a function / procedure / method in any language.

That means your code should be:

CallableStatement cs = con.prepareCall("{call calc(?,?,?,?,?,?)}");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM