zoukankan      html  css  js  c++  java
  • jdbcTemplate call plsql function

    总是忘记相关的语法,记录下以备查询.

    private String genSql = "{call PACK_XXX_MGMT.INSERT_USER_TOKEN(?, ?)}"; // procedure
    private String selSql = "{? = call PACK_XXX.GET_USER_ID_BY_TOKEN(?)}"; // function
    
    
    public String someFunction(final String token) {
      String userId = null;
            try{
    
                userId = jdbcTemplate.execute(selSql, new CallableStatementCallback<String>() {
                    public String doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
                        cs.registerOutParameter(1, java.sql.Types.VARCHAR);
                        cs.setString(2, token);
                        cs.execute();
                        return cs.getString(1);
                    }
                });
            }catch(DataAccessException e){
                //
            }
            
            return userId;
        }
    
        public String someFunction() {
    

    final String token = "hello"; final String userName = "world" jdbcTemplate.execute(genSql, new CallableStatementCallback<Void>() { public Void doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException { cs.setString(1, userName); cs.setString(2, token); cs.execute(); return null; } }); return token; }



    --------------------------------------
    Regards,
    FangwenYu
  • 相关阅读:
    正则表达式
    JS逻辑算法
    js函数
    JS运算符的应用
    JS课堂笔记
    json模块学习
    什么是面向对象,以及如何定义对象,实例化对象
    什么是面向过程,以及代码展示
    什么是元类,以及用type类来产生类.
    python下载安装
  • 原文地址:https://www.cnblogs.com/fangwenyu/p/3067366.html
Copyright © 2011-2022 走看看