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:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseClusterTable.java

public int nextSecFormIdGen(CFAstAuthorization Authorization, CFAstClusterPKey PKey) {
    final String S_ProcName = "nextSecFormIdGen";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }//  ww  w  . ja  va  2s  .  c o m
    Connection cnx = schema.getCnx();
    long Id = PKey.getRequiredId();

    CallableStatement stmtSelectNextSecFormIdGen = null;
    try {
        String sql = "{ call sp_next_secformidgen( ?" + ", " + "?" + " ) }";
        stmtSelectNextSecFormIdGen = cnx.prepareCall(sql);
        int argIdx = 1;
        stmtSelectNextSecFormIdGen.registerOutParameter(argIdx++, java.sql.Types.INTEGER);
        stmtSelectNextSecFormIdGen.setLong(argIdx++, Id);
        stmtSelectNextSecFormIdGen.execute();
        int nextId = stmtSelectNextSecFormIdGen.getInt(1);
        return (nextId);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtSelectNextSecFormIdGen != null) {
            try {
                stmtSelectNextSecFormIdGen.close();
            } catch (SQLException e) {
            }
            stmtSelectNextSecFormIdGen = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseClusterTable.java

public int nextSecGroupIdGen(CFAstAuthorization Authorization, CFAstClusterPKey PKey) {
    final String S_ProcName = "nextSecGroupIdGen";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }/*from   w ww. j a  va2s.c o  m*/
    Connection cnx = schema.getCnx();
    long Id = PKey.getRequiredId();

    CallableStatement stmtSelectNextSecGroupIdGen = null;
    try {
        String sql = "{ call sp_next_secgroupidgen( ?" + ", " + "?" + " ) }";
        stmtSelectNextSecGroupIdGen = cnx.prepareCall(sql);
        int argIdx = 1;
        stmtSelectNextSecGroupIdGen.registerOutParameter(argIdx++, java.sql.Types.INTEGER);
        stmtSelectNextSecGroupIdGen.setLong(argIdx++, Id);
        stmtSelectNextSecGroupIdGen.execute();
        int nextId = stmtSelectNextSecGroupIdGen.getInt(1);
        return (nextId);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtSelectNextSecGroupIdGen != null) {
            try {
                stmtSelectNextSecGroupIdGen.close();
            } catch (SQLException e) {
            }
            stmtSelectNextSecGroupIdGen = null;
        }
    }
}

From source file:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java

@Override
public int addDevice(final Device device) {
    int uid = -1;

    Connection conn = null;//  w ww .  ja  v  a 2 s  . c o  m
    CallableStatement stmt = null;
    ResultSet rs = null;

    try {
        conn = _dataSource.getConnection();

        stmt = conn.prepareCall("{call SP_REGISTERDEVICE (?,?,?,?)}");
        stmt.registerOutParameter(1, Types.INTEGER);
        stmt.setInt(2, device.getUserUid());
        stmt.setString(3, device.getDeviceId());
        stmt.setString(4, device.getDeviceType());
        stmt.execute();

        uid = stmt.getInt(1);
    } catch (SQLException e) {
        LOG.error(Throwables.getStackTraceAsString(e));
    } finally {
        DbUtils.closeQuietly(conn, stmt, rs);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("DEVICE [method:{} result:{}]", new Object[] { "edit", uid });
    }

    return uid;
}

From source file:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java

@Override
public int editAuction(final Auction auction) {
    int uid = -1;

    Connection conn = null;/*from w w  w  .  j  a v  a 2 s  . co m*/
    CallableStatement stmt = null;
    ResultSet rs = null;

    try {
        conn = _dataSource.getConnection();

        stmt = conn.prepareCall("{call SP_EDITAUCTION (?,?,?,?,?,?)}");
        stmt.registerOutParameter(1, Types.INTEGER);
        stmt.setString(2, auction.getName());
        stmt.setDate(3, new Date(auction.getStartDate()));
        stmt.setDate(4, new Date(auction.getEndDate()));
        stmt.setString(5, auction.getLogoUrl());
        stmt.setString(6, auction.getColor());
        stmt.execute();

        uid = stmt.getInt(1);
    } catch (SQLException e) {
        LOG.error(Throwables.getStackTraceAsString(e));
    } finally {
        DbUtils.closeQuietly(conn, stmt, rs);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("AUCTION [method:{} result:{}]", new Object[] { "edit", uid });
    }

    return uid;
}

From source file:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java

@Override
public int editUser(final User user) {
    int uid = -1;

    Connection conn = null;/*from  www .  j  a v a  2 s .com*/
    CallableStatement stmt = null;

    try {
        conn = _dataSource.getConnection();

        stmt = conn.prepareCall("{call SP_EDITUSER (?,?,?,?,?,?,?)}");
        stmt.registerOutParameter(1, Types.INTEGER);
        stmt.setInt(2, user.getAuctionUid());
        stmt.setString(3, user.getBidderNumber());
        stmt.setString(4, user.getFirstName());
        stmt.setString(5, user.getLastName());
        stmt.setString(6, user.getPasswordHash());
        stmt.setInt(7, user.getRole().getId());
        stmt.execute();

        uid = stmt.getInt(1);
    } catch (SQLException e) {
        LOG.error(Throwables.getStackTraceAsString(e));
        uid = -1;
    } finally {
        DbUtils.closeQuietly(conn, stmt, null);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("USER [method:{} result:{}]", new Object[] { "add", uid });
    }

    return uid;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseSchema.java

public int nextMimeTypeIdGen() {
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "nextMimeTypeIdGen",
                "Not in a transaction");
    }/*from   w ww  . j a  va2  s.  c o m*/
    CallableStatement stmtNext = null;
    try {
        final String sql = "{ call sp_next_mimetypeidgen( ? ) }";
        stmtNext = cnx.prepareCall(sql);
        stmtNext.registerOutParameter(1, java.sql.Types.INTEGER);
        stmtNext.execute();
        int nextId = stmtNext.getInt(1);
        return (nextId);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "nextMimeTypeIdGen", e);
    } finally {
        if (stmtNext != null) {
            try {
                stmtNext.close();
            } catch (SQLException e) {
            }
            stmtNext = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseSchema.java

public int nextServiceTypeIdGen() {
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "nextServiceTypeIdGen",
                "Not in a transaction");
    }/*from  ww  w .  ja v a  2  s .  c o  m*/
    CallableStatement stmtNext = null;
    try {
        final String sql = "{ call sp_next_servicetypeidgen( ? ) }";
        stmtNext = cnx.prepareCall(sql);
        stmtNext.registerOutParameter(1, java.sql.Types.INTEGER);
        stmtNext.execute();
        int nextId = stmtNext.getInt(1);
        return (nextId);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "nextServiceTypeIdGen", e);
    } finally {
        if (stmtNext != null) {
            try {
                stmtNext.close();
            } catch (SQLException e) {
            }
            stmtNext = null;
        }
    }
}

From source file:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java

@Override
public int editItem(final Item item) {
    int uid = -1;

    Connection conn = null;//from w  ww . ja v a2 s.c  o m
    CallableStatement stmt = null;

    try {
        conn = _dataSource.getConnection();

        stmt = conn.prepareCall("{call SP_EDITITEM (?,?,?,?,?,?,?,?,?,?,?)}");
        stmt.registerOutParameter(1, Types.INTEGER);
        stmt.setInt(2, item.getAuctionUid());
        stmt.setString(3, item.getItemNumber());
        stmt.setString(4, item.getName());
        stmt.setString(5, item.getDescription());
        stmt.setString(6, item.getCategory());
        stmt.setString(7, item.getSeller());
        stmt.setDouble(8, item.getValPrice());
        stmt.setDouble(9, item.getMinPrice());
        stmt.setDouble(10, item.getIncPrice());
        stmt.setString(11, item.getUrl());

        stmt.execute();

        uid = stmt.getInt(1);
    } catch (SQLException e) {
        LOG.error(Throwables.getStackTraceAsString(e));

        uid = -1;
    } finally {
        DbUtils.closeQuietly(conn, stmt, null);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("ITEM [method:{} result:{}]", new Object[] { "edit", uid });
    }

    return uid;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseSchema.java

public boolean isSystemUser(CFAstAuthorization Authorization) {
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isSystemUser",
                "Not in a transaction");
    }//  www.java 2  s.  c  o  m
    CallableStatement stmtSecurityCheck = null;
    try {
        final String sql = "{ call sp_is_system_user( ?, ? ) }";
        stmtSecurityCheck = cnx.prepareCall(sql);
        stmtSecurityCheck.registerOutParameter(1, java.sql.Types.INTEGER);
        stmtSecurityCheck.setString(2, Authorization.getSecUserId().toString());
        stmtSecurityCheck.execute();
        int isAuthorized = stmtSecurityCheck.getInt(1);
        if (isAuthorized == 0) {
            return (false);
        } else {
            return (true);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "isSystemUser", e);
    } finally {
        if (stmtSecurityCheck != null) {
            try {
                stmtSecurityCheck.close();
            } catch (SQLException e) {
            }
            stmtSecurityCheck = null;
        }
    }
}

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

/**
 * ?CIQ?//from w  w w.ja  va 2 s  .  co m
 * @return
 */
public static int saveCIQGoodsInfo(CEMSGoodsDataDto goodsDto) {
    int retCode = -1;
    Connection conn = null;
    CallableStatement proc = null;
    String call = "{call Pro_SaveCIQGoodsInfo(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}";
    try {
        conn = DBPool.ds.getConnection();
        proc = conn.prepareCall(call);
        proc.setString(1, goodsDto.getDecl_No());
        proc.setString(2, goodsDto.getGoods_No());
        proc.setString(3, goodsDto.getHS_Code());
        proc.setString(4, goodsDto.getGoods_CName());
        proc.setString(5, goodsDto.getGoods_EName());
        proc.setString(6, goodsDto.getGoods_Model());
        proc.setString(7, goodsDto.getOrigin_Place_Code());
        proc.setString(8, goodsDto.getOrigin_Country_Code());
        proc.setString(9, goodsDto.getWeight());
        proc.setString(10, goodsDto.getWeight_Unit_Code());
        proc.setString(11, goodsDto.getSTD_Weight());
        proc.setString(12, goodsDto.getSTD_Weight_Unit_Code());
        proc.setString(13, goodsDto.getQTY());
        proc.setString(14, goodsDto.getQTY_Unit_Code());
        proc.setString(15, goodsDto.getSTD_QTY());
        proc.setString(16, goodsDto.getSTD_QTY_Unit_Code());
        proc.setString(17, goodsDto.getPack_Number());
        proc.setString(18, goodsDto.getPack_Type_Code());
        proc.setString(19, goodsDto.getCCY());
        proc.setString(20, goodsDto.getRate());
        proc.setString(21, goodsDto.getPrice());
        proc.setString(22, goodsDto.getGoods_Values());
        proc.setString(23, goodsDto.getValues_USD());
        proc.setString(24, goodsDto.getValues_RMB());
        proc.setString(25, goodsDto.getCIQ_CODE());
        proc.setString(26, goodsDto.getINSP_MODE_CODE());
        proc.setString(27, goodsDto.getCONDITION_FLAG());
        proc.setString(28, goodsDto.getWASTE_FLAG());
        proc.setString(29, goodsDto.getCHECKUP_TYPE_CODE());
        proc.setString(30, goodsDto.getCHECKUP_WORK_CODE());
        proc.setString(31, goodsDto.getSITUATION_CODE());
        proc.setString(32, goodsDto.getSITUATION_LEVEL());
        proc.setString(33, goodsDto.getPURPOSE_CODE());
        proc.setString(34, goodsDto.getNOTIFY_NOS());
        proc.setString(35, goodsDto.getPROD_NO());
        proc.setString(36, goodsDto.getCOMBBATCH_NO());
        proc.registerOutParameter(37, Types.INTEGER);
        proc.execute();
        retCode = proc.getInt(37);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        log.error("N30", e);
    } catch (Exception e) {
        log.error("N31", e);
    } finally {
        try {
            if (proc != null) {
                proc.close();
            }
            if (conn != null) {
                conn.close();
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            log.error("N32", e);
        }
    }
    return retCode;
}