The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
July 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

RE: Executing Stored Procedures

Posted by Kishori Sharan on July 17, 2000 at 12:53 PM

Hi

Your error
"Error : Method setInt(int,java.lang.String) not found in interface java.sql.CallableStatement.
cs.setInt(i,DeptId);"

indicates that the second argument you are passing to setInt is of String type. However, for setInt's signature is as follows which requires int as the second argument. Please check the datatype of "DeptId"

public void setInt(int parameterIndex,int x) throws SQLException

Thanx
Kishori


> /*Part of the code where the connections are established, and i am trying to execure a stored procedure.
> My stored procedure needs three parameter to be passed. One integer and two string values.
> Please look into the code and try fixing the bug .
> */

> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.sql.*;
> import java.io.*;
> import java.util.*;
> import java.lang.*;

> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> Connection con = DriverManager.getConnection("jdbc:odbc:myserver","sa","");
> CallableStatement cs= con.prepareCall("{call SaveDept(?,?,?)}");
> cs.setInt(1,DeptId);
> cs.setString(2,DeptName);
> cs.setString(3,DeptDesc);
> cs.executeQuery();

> Error : Method setInt(int,java.lang.String) not found in interface java.sql.CallableStatement.
> cs.setInt(i,DeptId);






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us