aspose file tools*
The moose likes JDBC and the fly likes error in calling a procedure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "error in calling a procedure" Watch "error in calling a procedure" New topic
Author

error in calling a procedure

siva sankar
Ranch Hand

Joined: Jul 13, 2006
Posts: 68
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

Joined: Dec 14, 2006
Posts: 35
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error in calling a procedure