zoukankan      html  css  js  c++  java
  • Java调用oracle函数

     package com.phome.dao;

    import java.sql.CallableStatement;
    import java.sql.Connection;
    import java.sql.SQLException;
    import java.sql.Types;

    import com.phome.db.DBHerper;
    //Java调用oracle函数
    public class FunctionTest extends DBHerper{
     public int testFunction(int num1,int num2){
      int tem = 0;
      Connection conn = null;
      CallableStatement csmt = null;
      try {
       conn = super.getConnection();
       csmt = conn.prepareCall("{?=call add_two_num(?,?)}");
       csmt.registerOutParameter(1, Types.INTEGER);
       csmt.setInt(2, num1);
       csmt.setInt(3, num2);
       csmt.execute();
       tem = csmt.getInt(1);
      } catch (SQLException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
      }finally{
       try {
        csmt.close();
        conn.close();
       } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
       }
      }
      return tem;
     }
     public static void main(String[] args) {
      FunctionTest ft = new FunctionTest();
      int tem = ft.testFunction(10,20);
      System.out.println(tem);
     }
    }

  • 相关阅读:
    用react的ReactCSSTransitionGroup插件实现简单的弹幕动画
    composer安装yii2问题总结
    记阿里笔试经历
    JVM, JRE,JDK 的区别
    HTML
    Http协议
    操作系统和网络基础知识
    网络基础之网络协议
    计算机硬件知识
    计算机硬件历史
  • 原文地址:https://www.cnblogs.com/zhougaojun/p/2999082.html
Copyright © 2011-2022 走看看