0

I need to call a stored procedure using dblink and Java, I've got this code calling the stored procedure with jdbc, but now I need to do the same call using dblink

this is the call using JDBC

String sqlQuery = "{ CALL ACCUMULATED.GENERAR_ACUMULATED (?,?,?) }";


DatabaseConnection connection = new DatabaseConnection();

 try {
     int[] returnSQLTypes = { Types.VARCHAR };
     Object[] returnValues = null;
     List args = new ArrayList();

 args.add(this.getCompanyCodeNgsoft(companyCode));
 args.add(codUsuario);
 args.add("S");


    connection.connect(DatabaseConnection.NGSOFT_DATA_SOURCE_NAME);
     returnValues = connection.executeStoreProcedure(sqlQuery, args,
      returnSQLTypes);

     String swSuccessful = (String) returnValues[0];

     if ((swSuccessful != null)
      && swSuccessful.trim().equalsIgnoreCase("S")) {
  successful = true;
     } else {
  successful = false;
     }
 } catch (SQLException ex) {
     throw new GenerateInterfacesException(getMessageFac().getMessage(
      ex.getErrorCode()));
 } finally {
     try {
  connection.disconnect();
     } catch (SQLException ex1) {
  throw new GenerateInterfacesException(getMessageFac()
   .getMessage(ex1.getErrorCode()));
     }
 }

thanks

1 Answers1

1

Calling a stored procedure over a database link should be as simple as adding an @ sign and the database link name after the stored procedure, for example:

String sqlQuery = "{ CALL ACCUMULATED.GENERAR_ACUMULATED@your_db_link_name(?,?,?) }";
Luke Woodward
  • 63,336
  • 16
  • 89
  • 104