zoukankan      html  css  js  c++  java
  • CallableStatement

    用于调用数据库的存储过程

     1 import java.sql.CallableStatement;
     2 import java.sql.Connection;
     3 import java.sql.DriverManager;
     4 import java.sql.PreparedStatement;
     5 import java.sql.Types;
     6 
     7 
     8 
     9 
    10 public class TestCallable {
    11 
    12     /**
    13      * @param args
    14      */
    15     public static void main(String[] args) throws Exception{
    16     
    17         Connection conn = null;
    18         Class.forName("oracle.jdbc.driver.OracleDriver");
    19         conn  = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ELLENIOU", "scott", "tiger");
    20         
    21 //p为在数据库创建的过程
    22         CallableStatement cs = conn.prepareCall("{call p(?,?,?,?)}");
    23         cs.registerOutParameter(3, Types.INTEGER);
    24         cs.registerOutParameter(4, Types.INTEGER);
    25         cs.setInt(1, 3);
    26         cs.setInt(2, 4);
    27         cs.setInt(4, 5);
    28         cs.execute();
    29         System.out.println(cs.getInt(3));
    30         System.out.println(cs.getInt(4));
    31         cs.close();
    32         conn.close();
    33 
    34     }
    35 
    36 }
  • 相关阅读:
    CSV
    矛与盾热血江湖实现喊话功能
    IDA 使用小结
    OD 命令行插件支持的命令
    Qt TreeView
    矛与盾内存数据的分析
    Windows 内核 I/O 端口操作
    矛与盾注入到目标进程
    Qt 多级menu
    C# 美元转中文
  • 原文地址:https://www.cnblogs.com/elleniou/p/2639991.html
Copyright © 2011-2022 走看看