Example usage for java.sql CallableStatement getInt

List of usage examples for java.sql CallableStatement getInt

Introduction

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

Prototype

int getInt(String parameterName) throws SQLException;

Source Link

Document

Retrieves the value of a JDBC INTEGER parameter as an int in the Java programming language.

Usage

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

/**
 * ??/*from w  w  w  .j a v  a2 s  . co m*/
 */
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 a 2  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.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.c om
        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;
}

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

public int updateNotification(long userId, String status, String type) {
    int updated = 0;
    Connection connection = null;
    CallableStatement cstmt = null;
    try {//w w  w.  j  a  va2 s. c o  m
        connection = dataSource.getConnection();
        cstmt = connection.prepareCall("{call wp_update_push_notification(?,?,?,?)}");
        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;
}

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

public int checkResetLink(String uuid, String userId, String ip) {
    Connection connection = null;
    CallableStatement cstmt = null;
    int rvalue = -1;
    try {/*  ww  w.  jav a2  s  . co m*/
        connection = dataSource.getConnection();
        cstmt = connection.prepareCall("{call wp_check_reset_link(?,?,?,?)}");
        cstmt.setString(1, userId);
        cstmt.setString(2, uuid);
        cstmt.setString(3, ip);
        cstmt.registerOutParameter(4, java.sql.Types.INTEGER);

        cstmt.execute();

        rvalue = cstmt.getInt(4);
        log.info("Rvalue Check ResetLink : " + rvalue);

    } 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 rvalue;
}

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

public int resetPassword(String uuid, String userId, String password, String ip) {
    Connection connection = null;
    CallableStatement cstmt = null;
    int rvalue = -1;
    try {/*from w  w w . jav  a 2  s  . c om*/
        connection = dataSource.getConnection();
        cstmt = connection.prepareCall("{call wp_reset_pwd(?,?,?,?,?)}");
        cstmt.setString(1, userId);
        cstmt.setString(2, uuid);
        cstmt.setString(3, password);
        cstmt.setString(4, ip);
        cstmt.registerOutParameter(5, java.sql.Types.INTEGER);

        cstmt.execute();

        rvalue = cstmt.getInt(5);

    } 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 rvalue;
}

From source file:de.unibremen.informatik.tdki.combo.data.DBLayout.java

private boolean projectExists(String project) {
    CallableStatement callableStatement = null;
    boolean projectExists = false;
    try {//w ww .j ava 2s  . c om
        callableStatement = connection.prepareCall("CALL combo_project_exists('" + project + "',?)");
        callableStatement.registerOutParameter(1, java.sql.Types.INTEGER);
        callableStatement.executeUpdate();

        projectExists = (callableStatement.getInt(1) != 0);
    } catch (SQLException ex) {
        throw new RuntimeException(ex);
    } finally {
        DbUtils.closeQuietly(callableStatement);
    }
    return projectExists;
}

From source file:de.unibremen.informatik.tdki.combo.data.DBLayout.java

/**
 *
 * @param project/*from  w  w  w  .  j a v  a 2  s .  c o m*/
 * @return true if the project already exists
 */
public boolean createProject(String project) {
    CallableStatement callableStatement = null;
    boolean projectExists = false;
    try {
        callableStatement = connection.prepareCall("CALL combo_create_project('" + project + "',?)");
        callableStatement.registerOutParameter(1, java.sql.Types.INTEGER);
        callableStatement.executeUpdate();

        projectExists = (callableStatement.getInt(1) != 0);
    } catch (SQLException ex) {
        throw new RuntimeException(ex);
    } finally {
        DbUtils.closeQuietly(callableStatement);
    }
    return projectExists;
}

From source file:de.awtools.grooocle.varray.VarrayTest.java

@Test
public void testOraclesVarray() throws Exception {
    CallableStatement cs = null;
    try {/*from   ww w .ja  v  a2 s  .c  o m*/
        String arrayElements[] = { "Test3", "Test4", "Test5" };
        ArrayDescriptor desc = ArrayDescriptor.createDescriptor("T_STRING_VARRAY", conn);
        ARRAY newArray = new ARRAY(desc, conn, arrayElements);

        String spCall = "{ call call_me(?, ?) }";
        cs = conn.prepareCall(spCall);
        cs.setArray(1, newArray);
        cs.registerOutParameter(2, java.sql.Types.INTEGER);

        cs.execute();
        assertEquals(3, cs.getInt(2));
    } finally {
        if (cs != null) {
            cs.close();
        }
    }

}

From source file:com.aw.core.dao.DAOSql.java

protected void dbmsOutputPrint(Connection conn, StringBuffer buf) throws java.sql.SQLException {
    String getLineSql = "begin dbms_output.get_line(?,?); end;";
    CallableStatement stmt = conn.prepareCall(getLineSql);
    boolean hasMore = true;
    stmt.registerOutParameter(1, Types.VARCHAR);
    stmt.registerOutParameter(2, Types.INTEGER);
    while (hasMore) {
        boolean status = stmt.execute();
        hasMore = (stmt.getInt(2) == 0);
        if (hasMore) {
            buf.append(stmt.getString(1)).append("\n");
        }/*from   w  w  w  .  j  a  v  a2  s.co m*/
    }
    stmt.close();
}