简体   繁体   English

使用dblink和Java调用存储过程

[英]call stored procedure using dblink and Java

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 我需要使用dblink和Java调用存储过程,我已经获得了这段代码使用jdbc调用存储过程,但是现在我需要使用dblink进行相同的调用

this is the call using JDBC 这是使用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 谢谢

通过数据库链接调用存储过程应该像在存储过程之后添加@符号和数据库链接名称一样简单,例如:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM