简体   繁体   English

使用Netbeans时出现此错误pls 103103

[英]I'm getting this error pls 00103 when using netbeans

I have established a connection to my oracle database with username system 我已经使用用户名系统建立了到oracle数据库的连接

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. 连接成功,我可以执行所有基本的sql操作,例如insert,update,delete ...,但是我无法执行存储过程。 While i'm trying to call my stored procedure from netbeans i'm getting some errors . 当我尝试从netbeans调用存储过程时,出现了一些错误。 Please help me in solving this issue. 请帮助我解决这个问题。

netbeans buttonPerformed code netbeans按钮执行代码

    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: 当我在sqlplus中运行以下命令时:

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

I'm getting the intended o/p. 我正在获取预期的o / p。 But when i do the same in netbeans i'm not getting the intended op but some error. 但是,当我在netbeans中执行相同操作时,我没有得到预期的操作,但出现了一些错误。

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

Quick help is appreciated. 快速帮助表示赞赏。 Thanks in advance... 提前致谢...

The javadoc of CallableStatement says: CallableStatement的Javadoc说:

The interface used to execute SQL stored procedures. 用于执行SQL存储过程的接口。 The JDBC API provides a stored procedure SQL escape syntax that allows stored procedures to be called in a standard way for all RDBMSs. JDBC API提供了存储过程SQL转义语法,该语法允许所有RDBMS以标准方式调用存储过程。 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. 如果使用,则结果参数必须注册为OUT参数。 The other parameters can be used for input, output or both. 其他参数可用于输入,输出或两者。 Parameters are referred to sequentially, by number, with the first parameter being 1. 参数按编号顺序引用,第一个参数为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(?,?,?,?,?,?)}");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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