• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error in calling a procedure

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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("jdbc:oracle: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
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic