使用vertx jdbc客户端执行db2存储的proc执行 [英] Db2 stored proc execution using vertx jdbc client

查看:96
本文介绍了使用vertx jdbc客户端执行db2存储的proc执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是vertx的新手我正在尝试使用vertx jdbc客户端为db2执行SP,但不确定如何继续处理潜在客户

I m new to vertx i m trying to execute an SP for db2 , using vertx jdbc client, but not sure how to proceed any leads

推荐答案

vertx文档指出:

The vertx documentation states:

执行可调用语句(SQL函数或SQL程序),您可以使用callWithParams.

To execute a callable statement (either SQL functions or SQL procedures) you can use callWithParams .

这采用标准JDBC格式的可调用语句{调用func_proc_name()},可以选择包含参数占位符例如:{调用func_proc_name(?,?)},一个包含参数值,最后是包含输出类型的JsonArray例如:[null,'VARCHAR'].

This takes the callable statement using the standard JDBC format { call func_proc_name() }, optionally including parameter place holders e.g.: { call func_proc_name(?, ?) }, a JsonArray containing the parameter values and finally a JsonArray containing the output types e.g.: [null, 'VARCHAR'].

请注意,输出类型的索引与params一样重要大批.如果返回值是第二个参数,则输出数组必须包含一个空值作为第一个元素.

Note that the index of the output type is as important as the params array. If the return value is the second argument then the output array must contain a null value as the first element.

当存储过程具有输入参数和结果集时,文档将给出以下示例:

When the stored procedure has input parameters and a result-set, the documentation gives this example:

String func = "{ call customer_lastname(?, ?) }";

connection.callWithParams(func, new JsonArray().add("John"), new JsonArray().addNull().add("VARCHAR"), res -> {

  if (res.succeeded()) {
    ResultSet result = res.result();
  } else {
    // Failed!
  }
});

当存储过程没有结果集或输出参数时,文档将给出以下示例:

When the stored procedure has no result-set or output parameters, the documentation gives this example:

String func = "{ call new_customer(?, ?) }";

connection.callWithParams(func, new JsonArray().add("John").add("Doe"), null, res -> {

  if (res.succeeded()) {
    // Success!
  } else {
    // Failed!
  }
});

这篇关于使用vertx jdbc客户端执行db2存储的proc执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆