Title: RES: [java-list] CallableStatement Com Oracle

Mike,

        Esta e uma sugestao nao testada.
       
        :::::: Seu Codigo :::::::::


     ctmQuery = conConnectionDB.prepareCall(strCommand);

      // Registering input parameters
      ctmQuery.setString(1,pstrLDAPName);

      // Registering output parameters
      ctmQuery.registerOutParameter(2,OracleTypes.NUMBER);  // Oracle error code
      ctmQuery.registerOutParameter(3,OracleTypes.VARCHAR); // Oracle error description
      ctmQuery.registerOutParameter(4,OracleTypes.VARCHAR); // Role Name

      // Execute stored procedure and get the resultset
        // Minha sugestao
      ResultSet rs = ctmQuery.executeQuery();
      intErrorCode = rs.getInt(2);
      strErrorDesc = rs.getString(3);
      strRoleName  = rs.getString(4);
       
        rs.close();
        // Fim da alteracao
      ctmQuery.close(); 

        ::::: O resto do codigo :::::::


        Se funcionar voce poderia me dar um retorno ?

        []'s

        Luciano Vilela

-----Mensagem original-----
De: Mike Moreira [mailto:[EMAIL PROTECTED]]
Enviada em: Ter�a-feira, 18 de Dezembro de 2001 10:54
Para: Grupo Discussao Java
Assunto: [java-list] CallableStatement Com Oracle
Prioridade: Alta


Ola ,

Galera estou com um problema que provavelmente eh comum mas nao achei nada na net. Eh o seguinte :

Tenho uma estrutura de programacao onde tenho varios Beans e cada metodo desses beans chamam uma procedure que devolve um resultado, ate ai normal e comum. O problema eh que para chamar essas procedures eu uso o comando Connection.prepareCall(<Chamada da Package>), depois dou um execute e logo apos o close. Ai vem o problema

Ao executar o prepareCall o JDBC cria um cursor aberto no oracle e ao dar o execute ele cria um segundo e quando chamo o Close o JDBC somente fecha o segundo, o primeiro fica aberto e so fecha quando o objeto Connection e destruido. Eu ja fiz varios testes com o oracle e outras linguagens (Delphi | PowerBuilder | Forms) e isso nao aconteceu, portanto acho que eh um problema do JDBC se alguem tiver alguma ideia ou dica ... por favor mander para mim.

Obrigado,

Ex.: de metodo
*********************************************************************************
ctmQuery  e conConnectionDB sao privados do objeto
*********************************************************************************

  public String getRoleName(String pstrLDAPName)throws OFSWebException {

    String  strCommand         = null;
    int     intErrorCode       = 0;
    String  strErrorDesc       = null;
    String  strOrder           = null;
    String  strRoleName        = null;

    try {
      strCommand = "{call KOF_OF_RO.POF_OF_ROSelRoleName(?,?,?,?)}";

      ctmQuery = conConnectionDB.prepareCall(strCommand);

      // Registering input parameters
      ctmQuery.setString(1,pstrLDAPName);

      // Registering output parameters
      ctmQuery.registerOutParameter(2,OracleTypes.NUMBER);  // Oracle error code
      ctmQuery.registerOutParameter(3,OracleTypes.VARCHAR); // Oracle error description
      ctmQuery.registerOutParameter(4,OracleTypes.VARCHAR); // Role Name

      // Execute stored procedure and get the resultset
      ctmQuery.execute();
      intErrorCode = ctmQuery.getInt(2);
      strErrorDesc = ctmQuery.getString(3);
      strRoleName  = ctmQuery.getString(4);

      ctmQuery.close();

      if (intErrorCode != 0) {
        throw new OFSWebException(intErrorCode,strErrorDesc);
      }
    }
    catch (OFSWebException excOFS) {
      throw new OFSWebException(excOFS.getErrorCode(), excOFS.getMessage());
    }
    catch (SQLException excSQL) {
      StringWriter stwError = new StringWriter();
      excSQL.printStackTrace( new PrintWriter(stwError));
      throw new OFSWebException(intErrorCode, stwError.toString());
    }
    catch (Exception excOther) {
      StringWriter stwError = new StringWriter();
      excOther.printStackTrace( new PrintWriter(stwError));
      throw new OFSWebException(iConstants.EXCEPTION_ERROR_CODE, stwError.toString());
    }
    return  strRoleName;
  }

*********************************************************************************
<><><><><><><><><><><><><><><><><><>
[]'s
Mike Moreira
CPA Sistemas de Informa��o
+55.11.4330-6066
[EMAIL PROTECTED]
<><><><><><><><><><><><><><><><><><>


------------------------------ LISTA SOUJAVA ----------------------------
http://www.soujava.org.br  -  Sociedade de Usu�rios Java da Sucesu-SP
d�vidas mais comuns: http://www.soujava.org.br/faq.htm
regras da lista: http://www.soujava.org.br/regras.htm
para sair da lista: envie email para [EMAIL PROTECTED]
-------------------------------------------------------------------------

Responder a