javajdbccallable-statementjava-stored-procedures

java.sql.SQLException: Could not find stored procedure


[dbo].[GetUserCredentials]
   @Company varchar(255),
   @SchedType varchar(255),
   @ShiftHours varchar(255),
   @UserRole varchar(255),
   @UserDesc varchar(255),
   @UserOwner varchar(255)
select ... from ... where ...

Stored Procedure ^

java code that calls the stored procedure

CallableStatement statement = con.prepareCall("{call GetUserCredentials}");
statement.execute();

Result

java.sql.SQLException: Could not find stored procedure 'GetUserCredentials'.


Solution

  • I can see that your stored procedure have missing input parameters, add "?" (number of input parameters) in the prepareCall statement eg.

    stmt = con.prepareCall("{call insertEmployee(?,?,?,?,?,?)}");
                stmt.setInt(1, id);
                stmt.setString(2, name);
                stmt.setString(3, role);
                stmt.setString(4, city);
                stmt.setString(5, country);
    

    look this article to understand it better