title: how to call a stored function from jdbc?
body: <p>I am creating a login page using custom tag, in the below code i want to execute a stored oracle function where that function will take 2 parameter (name,password) to authenticate and return a number.  But when i compile the below code it gives an error saying ( found: int) incompatible type.  please tell me where am i going wrong ? am i calling the function correctly ?</p>
  
  <pre><code>package pack.java;
  import pack.java.MyModel;
  import java.io.*;
  import java.lang.*;
  import javax.servlet.*;
  import javax.servlet.http.*;
  import javax.servlet.jsp.*;
  import javax.servlet.jsp.tagext.*;
  import java.sql.*;
  
  public class MyController extends TagSupport
  {
      HttpServletRequest request;
      HttpServletResponse response;
  
      public int doStartTag()throws JspException
      {
          request = (HttpServletRequest)pageContext.getRequest();              
          response = (HttpServletResponse)pageContext.getResponse();
          return EVAL_PAGE;
      }   
  
      public void check()
      {
          HttpSession mysession = request.getSession();
          Connection con;
          CallableStatement stmt;
          JspWriter out = pageContext.getOut();
          try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
          }
          catch(ClassNotFoundException ex) {}
          try {         
              String aa = (String)MyModel.name.trim();
              String bb = (String)MyModel.pass.trim();
              con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","gaurav","oracle");
              stmt = con.prepareCall("select usercheck1(?,?) from dual");
              stmt.setString(1, aa);
              stmt.setString(2, bb);       
              rs = stmt.executeQuery();
              try {
                  while (rs.next()) {
                      String empid = rs.getString (1);
                      mysession.setAttribute("user", empid);
                      if (empid != null) {
                          response.sendRedirect("/Myjsp/selectaction.jsp");
                      }
                      else
                          out.println("InValid User");
                  }
              }
              catch(Exception ex) {}
          }
          catch(SQLException ex) {}
      }
  
      public int doEndTag() throws JspException {
          check();
          return EVAL_PAGE;
      }
  }
  </code></pre>
  
  <p>below is the stored function</p>
  
  <pre><code>create or replace function usercheck1
      (uname varchar2, upass varchar2)
      return number
  as 
      numb number;
  begin
      select (employe_id)
        into numb
        from record
       where name = uname
         and password = upass;
      return numb;
  end usercheck1;
  /
  </code></pre>
  
  <p>executing the function using the below statement </p>
  
  <pre><code>select usercheck1 ('ghg','aa') from dual;
  </code></pre>