Java SQL Type callPro2(String sql, String[] inparameters, Integer[] outparameters)

Here you can find the source of callPro2(String sql, String[] inparameters, Integer[] outparameters)

Description

call Pro

License

Apache License

Declaration

public static CallableStatement callPro2(String sql, String[] inparameters, Integer[] outparameters) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.sql.*;

public class Main {
    private static Connection ct = null;
    private static String url = "";
    private static String username = "";
    private static String passwd = "";
    private static CallableStatement cs = null;

    public static CallableStatement callPro2(String sql, String[] inparameters, Integer[] outparameters) {
        try {/*  w  ww .j a v  a  2s .  c  om*/
            ct = getConnection();
            cs = ct.prepareCall(sql);
            if (inparameters != null) {
                for (int i = 0; i < inparameters.length; i++) {
                    cs.setObject(i + 1, inparameters[i]);
                }
            }
            //cs.registerOutparameter(2,oracle.jdbc.OracleTypes.CURSOR);
            if (outparameters != null) {
                for (int i = 0; i < outparameters.length; i++) {
                    cs.registerOutParameter(inparameters.length + 1 + i, outparameters[i]);
                }
            }
            cs.execute();
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e.getMessage());
        } finally {

        }
        return cs;
    }

    public static Connection getConnection() {
        try {
            ct = DriverManager.getConnection(url, username, passwd);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ct;
    }
}

Related

  1. addParameter(PreparedStatement smt, int index, Object value)
  2. adjustLevel(String attribute, int type)
  3. columnClassName(int columnType)
  4. columnDisplaySize(int columnType)
  5. columnPrecision(int columnType)
  6. columnScale(int columnType)