Example usage for java.sql CallableStatement registerOutParameter

List of usage examples for java.sql CallableStatement registerOutParameter

Introduction

In this page you can find the example usage for java.sql CallableStatement registerOutParameter.

Prototype

default void registerOutParameter(String parameterName, SQLType sqlType) throws SQLException 

Source Link

Document

Registers the OUT parameter named parameterName to the JDBC type sqlType .

Usage

From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java

/**
 * ??/*from w ww .  j  ava2s  . c o m*/
 */
public static int declFlagAction(String declNo) {
    int retCode = -1;
    Connection conn = null;
    CallableStatement proc = null;
    String call = "{call Pro_DeclFlagAction(?,?)}";
    try {
        conn = DBPool.ds.getConnection();
        proc = conn.prepareCall(call);
        proc.setString(1, declNo);
        proc.registerOutParameter(2, Types.INTEGER);
        proc.execute();
        retCode = proc.getInt(2);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        log.error("N33", e);
    } catch (Exception e) {
        log.error("N34", e);
    } finally {
        try {
            if (proc != null) {
                proc.close();
            }
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            log.error("N35", e);
        }
    }
    return retCode;
}

From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java

/**
 * ?:?//ww w  . jav a2  s.c  o m
 * @return
 */
public static int checkRapidRelease(String declNo) {
    int retCode = -1;
    Connection conn = null;
    CallableStatement proc = null;
    ResultSet rs = null;
    String call = "{call Pro_CheckRapidRelease(?,?)}";
    try {
        conn = DBPool.ds.getConnection();
        proc = conn.prepareCall(call);
        proc.setString(1, declNo);
        proc.registerOutParameter(2, Types.INTEGER);
        proc.execute();
        retCode = proc.getInt(2);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        log.error("N60", e);
    } catch (Exception e) {
        log.error("N61", e);
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
            if (proc != null) {
                proc.close();
            }
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            log.error("N62", e);
        }
    }
    return retCode;
}

From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java

/**
 * ?????/*from w  w  w. j a  v  a 2s. c o  m*/
 * @param declNo
 * @return
 */
public static int checkDeclProductPerfect(String declNo) {
    int retCode = -1;
    Connection conn = null;
    CallableStatement proc = null;
    ResultSet rs = null;
    String call = "{call Pro_CheckDeclProductPerfect(?,?)}";
    try {
        conn = DBPool.ds.getConnection();
        proc = conn.prepareCall(call);
        proc.setString(1, declNo);
        proc.registerOutParameter(2, Types.INTEGER);
        proc.execute();
        retCode = proc.getInt(2);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        log.error(e);
    } catch (Exception e) {
        log.error(e);
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
            if (proc != null) {
                proc.close();
            }
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            log.error(e);
        }
    }
    return retCode;
}

From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java

public static int checkDeclProductSampling(String declNo) {
    int retCode = -1;
    Connection conn = null;//from w w  w  .  ja v a2s.  c  om
    CallableStatement proc = null;
    ResultSet rs = null;
    String call = "{call Pro_CheckDeclProductSampling(?,?)}";
    try {
        conn = DBPool.ds.getConnection();
        proc = conn.prepareCall(call);
        proc.setString(1, declNo);
        proc.registerOutParameter(2, Types.INTEGER);
        proc.execute();
        retCode = proc.getInt(2);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        log.error("N57", e);
    } catch (Exception e) {
        log.error("N58", e);
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
            if (proc != null) {
                proc.close();
            }
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            log.error("N59", e);
        }
    }
    return retCode;
}

From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java

/**
 * ??/*from   w w  w  .j ava  2s  .com*/
 */
public static int checkEntExists(String entCode) {
    int retCode = -1;
    Connection conn = null;
    CallableStatement proc = null;
    String call = "{call Pro_CheckEntExists(?,?)}";
    try {
        conn = DBPool.ds.getConnection();
        proc = conn.prepareCall(call);
        System.out.println("entcode" + entCode);
        proc.setString(1, entCode);
        proc.registerOutParameter(2, Types.INTEGER);
        proc.execute();
        retCode = proc.getInt(2);
        System.out.println("retcode" + retCode);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        log.error("N39", e);
    } catch (Exception e) {
        log.error("N40", e);
    } finally {
        try {
            if (proc != null) {
                proc.close();
            }
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            log.error("N41", e);
        }
    }
    return retCode;
}

From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java

/**
 * ???????/*w  w w  . j av  a2  s  .  c  om*/
 */
public static int saveDeclProduct(String declNo, String entProductCode, String baseCode, String goodsNo) {
    int retCode = -1;
    Connection conn = null;
    CallableStatement proc = null;
    ResultSet rs = null;
    String call = "{call Pro_SaveDeclProduct(?,?,?,?,?)}";
    try {
        conn = DBPool.ds.getConnection();
        proc = conn.prepareCall(call);
        proc.setString(1, declNo);
        proc.setString(2, entProductCode);
        proc.setString(3, baseCode);
        proc.setString(4, goodsNo);
        proc.registerOutParameter(5, Types.INTEGER);
        proc.execute();
        retCode = proc.getInt(5);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        log.error("N54", e);
    } catch (Exception e) {
        log.error("N55", e);
    } finally {
        try {
            if (rs != null) {
                rs.close();
            }
            if (proc != null) {
                proc.close();
            }
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            log.error("N56", e);
        }
    }
    return retCode;
}

From source file:com.nortal.petit.core.dialect.OracleSqlDialect.java

@SuppressWarnings("unchecked")
@Override//from  w  w w  .  j av a2s.c o  m
public <B> B insertReturningId(JdbcOperations jdbcOperations, String sql, String idColumn,
        final Object... params) {
    final String actualSql = new StringBuilder("BEGIN ").append(sql)
            .append(" RETURNING " + idColumn + " INTO ?; END;").toString();
    try {
        return (B) jdbcOperations.execute(new CallableStatementCreator() {
            @Override
            public CallableStatement createCallableStatement(Connection con) throws SQLException {
                CallableStatement cs = con.prepareCall(actualSql);
                ArgPreparedStatementSetter.setValues(cs, params, 1);
                cs.registerOutParameter(params.length + 1, Types.DECIMAL);
                return cs;
            }
        }, new CallableStatementCallback<B>() {
            @Override
            public B doInCallableStatement(CallableStatement cs) throws SQLException, DataAccessException {
                cs.execute();
                BigDecimal bd = cs.getBigDecimal(params.length + 1);
                return (B) Long.valueOf(bd.longValue());
            }
        });
    } catch (RuntimeException e) {
        LOG.error("Error processing SQL '" + sql + "' with parameters: " + StringUtils.join(params, "; "));
        throw e;
    }
}

From source file:com.mobilewallet.common.dao.RegisterDAO.java

public void updateGCM(String userId, String gcmId) {
    Connection con = null;//from   w w w .j  a  v  a2  s  . c om
    CallableStatement cstmt = null;

    try {
        con = ds.getConnection();
        cstmt = con.prepareCall("{call wp_update_gcm(?,?,?)}");
        cstmt.setString(1, userId);
        cstmt.setString(2, gcmId);
        cstmt.registerOutParameter(3, java.sql.Types.VARCHAR);
        cstmt.execute();

    } catch (Exception ex) {

    } finally {
        try {
            if (cstmt != null) {
                cstmt.close();
            }
        } catch (Exception ex) {

        }
        try {
            if (con != null) {
                con.close();
            }
        } catch (Exception ex) {

        }
    }
}

From source file:com.mobilewallet.common.dao.ReferralIncentiveDAO.java

public String showInvitationStrig(long userId) {
    Connection connection = null;
    CallableStatement cstmt = null;
    String show = null;/*from www .  ja v  a  2  s . c o m*/

    try {
        connection = dataSource.getConnection();
        cstmt = connection.prepareCall("{call wp_show_invitation(?,?)}");
        cstmt.setLong(1, userId);
        cstmt.registerOutParameter(2, java.sql.Types.VARCHAR);

        cstmt.execute();

        show = cstmt.getString(2);

    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        try {
            if (cstmt != null) {
                cstmt.close();
            }
        } catch (Exception ex) {

        }
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (Exception ex) {

        }
    }

    return show;
}

From source file:com.mobilewallet.users.dao.PushNotificationsDAO.java

public int updateNotification(long userId, String status, String type) {
    int updated = 0;
    Connection connection = null;
    CallableStatement cstmt = null;
    try {/*from w ww . j a  v  a2 s  .  co m*/
        connection = dataSource.getConnection();
        cstmt = connection.prepareCall("{call UPDATE_PUSH_NOTIFICATIONS(?,?,?,?)}");
        cstmt.setLong(1, userId);
        cstmt.setString(2, status);
        cstmt.setString(3, type);
        cstmt.registerOutParameter(4, java.sql.Types.INTEGER);
        cstmt.execute();

        updated = cstmt.getInt(4);
    } catch (Exception ex) {

    } finally {
        try {
            if (cstmt != null) {
                cstmt.close();
            }
        } catch (Exception ex) {

        }
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (Exception ex) {

        }
    }
    return updated;
}