Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error in calling a procedure

 
siva sankar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i am using oracle 8i.I wrote a simple procedure.It is working on the backend.When i am trying to access the same procedure from a java program,i am getting the following exception


Exception is:java.sql.SQLException: invalid arguments in call.




Here is my java program .


import java.sql.*;
import java.util.*;

public class TestProc
{
public static void main(String args[]) throws Exception
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection

conn=DriverManager.getConnection("jdbcracle:thin:@localhost:1521:SIVA");
CallableStatement cstmt=conn.prepareCall("{ call task (?,?) }");
int a=10;
int b=20;
cstmt.setInt(1,a);
cstmt.setInt(2,b);
cstmt.executeQuery();
SQLWarning sqlw = cstmt.getWarnings();
System.out.println(sqlw);
}
catch(Exception e)
{
System.out.println("Exception is:"+e.toString());
}
}
}



Here is the procedure i wrote


create or replace procedure task(pone in number,ptwo in number)

as

begin

insert into emp1(eno,esal) values(pone,ptwo);

end task ;






Here is my database table

ENO NUMBER(5)
NAME VARCHAR2(5)
SAL NUMBER(5)



Please tell me why this exception is coming.


Thanks in Advance,

Regards,
Siva
 
Naveen Kumar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Check the No. of parameters to be passed to the SQL and make assumption in the same sequence.

In the URL you given localhost dont give the localhost give me the IP of your Oracle Database system.

Regards
kumar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic