Example usage for java.sql Types INTEGER

List of usage examples for java.sql Types INTEGER

Introduction

In this page you can find the example usage for java.sql Types INTEGER.

Prototype

int INTEGER

To view the source code for java.sql Types INTEGER.

Click Source Link

Document

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type INTEGER.

Usage

From source file:com.archivas.clienttools.arcutils.utils.database.ManagedJobSchema.java

/**
 * Updates the stats for all of the files passed in, and also updates the general job statistics
 * to reflect how many success/failures there were
 * //  w  w w  .j  a va2s .  c  o m
 * @param files
 *            -
 * @throws DatabaseException
 *             -
 */
@SuppressWarnings({ "ThrowableResultOfMethodCallIgnored" })
public void markFilesProcessed(Collection<FileStats> files) throws DatabaseException {
    synchronized (DatabaseResourceManager.DB_LOCK) {
        PooledDbConnection conn = null;
        try {

            conn = connPool.getConnection();
            PreparedStatement stmt = conn.prepareStatement(MARK_FILE_PROCESSED_STMT_NAME, markFileProcessedSql);
            conn.setAutoCommit(false);
            long totalCnt = 0;
            long totalSize = 0;
            long successCnt = 0;
            long successSize = 0;
            long failCnt = 0;
            long failSize = 0;
            long failDirCnt = 0;
            for (FileStats file : files) {
                FileStatus status = file.getStatus();
                switch (status) {
                case SUCCEEDED: {
                    if (file.includeInStats()) {
                        successCnt++;
                        successSize += file.getSize();
                    }
                    break;
                }
                case FAILED: {
                    if (file.includeInStats()) {
                        failCnt++;
                        failSize += file.getSize();
                        if (file.failedDuringFind()) {
                            // in this case we need to increment the total counts as well
                            totalCnt++;
                            totalSize += file.getSize(); // probably zero since we didn't
                                                         // get that far
                        }
                    }
                    if (file.getArcProcssFile().isDirectory()) {
                        failDirCnt++;
                    }
                    break;
                }
                default:
                    throw new RuntimeException("Unsupported file status: " + status);
                }
                stmt.clearParameters();
                stmt.setInt(1, file.getStatus().ordinal());
                stmt.setInt(2, file.getRetries());
                Date startTime = file.getStartTime();
                if (startTime != null) {
                    stmt.setLong(3, startTime.getTime());
                } else {
                    stmt.setNull(3, java.sql.Types.BIGINT);
                }
                Date endTime = file.getEndTime();
                if (endTime != null) {
                    stmt.setLong(4, endTime.getTime());
                } else {
                    stmt.setNull(4, java.sql.Types.BIGINT);
                }
                stmt.setLong(5, file.getRunTimeMs());

                if (file.getException() == null) {
                    stmt.setNull(6, java.sql.Types.VARCHAR);
                } else {
                    stmt.setString(6, file.getException().getMessage());
                }

                if (file.getStatusCode() == null) {
                    stmt.setNull(7, java.sql.Types.INTEGER);
                } else {
                    stmt.setInt(7, file.getStatusCode());
                }
                stmt.setLong(8, file.getDatabaseRecordId());

                stmt.addBatch();
            }

            // execute the batch statment to update all of the file rows
            stmt.executeBatch();

            // now update overall job stats to reflect these changes
            ManagedJobsSchema.getInstance().updateProcessedFilesStats(conn, jobId, totalCnt, totalSize,
                    successCnt, successSize, failCnt, failSize, failDirCnt);
            conn.commit();

        } catch (Exception e) {
            rollback(conn);
            throw new DatabaseException(DBUtils.getErrorMessage(
                    "An error occurred updating file stats on table " + qualifiedFilesTableName, e), e);
        } finally {
            connPool.returnConnection(conn);
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlContactListTable.java

public void updateContactList(CFAccAuthorization Authorization, CFAccContactListBuff Buff) {
    final String S_ProcName = "updateContactList";
    ResultSet resultSet = null;//w  ww .java2  s  .c  o  m
    try {
        long ContactListId = Buff.getRequiredContactListId();
        long TenantId = Buff.getRequiredTenantId();
        String Description = Buff.getRequiredDescription();
        Integer StripDigits = Buff.getOptionalStripDigits();
        int Revision = Buff.getRequiredRevision();
        Connection cnx = schema.getCnx();
        String sql = "select * from " + schema.getLowerSchemaDbName() + ".sp_update_ctclst( ?, ?, ?, ?, ?, ?"
                + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )";
        if (stmtUpdateByPKey == null) {
            stmtUpdateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtUpdateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtUpdateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtUpdateByPKey.setString(argIdx++, "CTL");
        stmtUpdateByPKey.setLong(argIdx++, ContactListId);
        stmtUpdateByPKey.setLong(argIdx++, TenantId);
        stmtUpdateByPKey.setString(argIdx++, Description);
        if (StripDigits != null) {
            stmtUpdateByPKey.setInt(argIdx++, StripDigits.intValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        resultSet = stmtUpdateByPKey.executeQuery();
        if (resultSet.next()) {
            CFAccContactListBuff updatedBuff = unpackContactListResultSetToBuff(resultSet);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
            Buff.setRequiredDescription(updatedBuff.getRequiredDescription());
            Buff.setOptionalStripDigits(updatedBuff.getOptionalStripDigits());
            Buff.setRequiredRevision(updatedBuff.getRequiredRevision());
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected a single-record response, " + resultSet.getRow() + " rows selected");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWContactListTable.java

public void updateContactList(CFAccAuthorization Authorization, CFAccContactListBuff Buff) {
    final String S_ProcName = "updateContactList";
    if ("CTL".equals(Buff.getClassCode())
            && (!schema.isTenantUser(Authorization, Buff.getRequiredTenantId(), "UpdateContactList"))) {
        throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                "Permission denied -- User not part of TSecGroup UpdateContactList");
    }/*w  w w . j  av  a 2 s .c  o m*/
    ResultSet resultSet = null;
    try {
        long ContactListId = Buff.getRequiredContactListId();
        long TenantId = Buff.getRequiredTenantId();
        String Description = Buff.getRequiredDescription();
        Integer StripDigits = Buff.getOptionalStripDigits();
        int Revision = Buff.getRequiredRevision();
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_update_ctclst( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?"
                + ", " + "?" + ", " + "?" + " )";
        if (stmtUpdateByPKey == null) {
            stmtUpdateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtUpdateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtUpdateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtUpdateByPKey.setString(argIdx++, "CTL");
        stmtUpdateByPKey.setLong(argIdx++, ContactListId);
        stmtUpdateByPKey.setLong(argIdx++, TenantId);
        stmtUpdateByPKey.setString(argIdx++, Description);
        if (StripDigits != null) {
            stmtUpdateByPKey.setInt(argIdx++, StripDigits.intValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        resultSet = stmtUpdateByPKey.executeQuery();
        if (resultSet.next()) {
            CFAccContactListBuff updatedBuff = unpackContactListResultSetToBuff(resultSet);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredDescription(updatedBuff.getRequiredDescription());
            Buff.setOptionalStripDigits(updatedBuff.getOptionalStripDigits());
            Buff.setRequiredRevision(updatedBuff.getRequiredRevision());
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected a single-record response, " + resultSet.getRow() + " rows selected");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseSchema.java

public boolean isTenantUser(CFSecurityAuthorization Authorization, long tenantId, String secGroupName) {
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isTenantUser",
                "Not in a transaction");
    }/*www.jav a  2  s  .com*/
    CallableStatement stmtSecurityCheck = null;
    try {
        final String sql = "{ call sp_is_tenant_user( ?, ?, ?, ? ) }";
        stmtSecurityCheck = cnx.prepareCall(sql);
        stmtSecurityCheck.registerOutParameter(1, java.sql.Types.INTEGER);
        stmtSecurityCheck.setLong(2, tenantId);
        stmtSecurityCheck.setString(3, secGroupName);
        stmtSecurityCheck.setString(4, 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(), "isTenantUser", e);
    } finally {
        if (stmtSecurityCheck != null) {
            try {
                stmtSecurityCheck.close();
            } catch (SQLException e) {
            }
            stmtSecurityCheck = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmMSSql.CFCrmMSSqlContactListTable.java

public void updateContactList(CFCrmAuthorization Authorization, CFCrmContactListBuff Buff) {
    final String S_ProcName = "updateContactList";
    ResultSet resultSet = null;/* w  w  w .j  a va 2 s.  co  m*/
    try {
        long ContactListId = Buff.getRequiredContactListId();
        long TenantId = Buff.getRequiredTenantId();
        String Description = Buff.getRequiredDescription();
        Integer StripDigits = Buff.getOptionalStripDigits();
        int Revision = Buff.getRequiredRevision();
        Connection cnx = schema.getCnx();
        String sql = "exec sp_update_ctclst ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", "
                + "?" + ", " + "?";
        if (stmtUpdateByPKey == null) {
            stmtUpdateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtUpdateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtUpdateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtUpdateByPKey.setString(argIdx++, "CTL");
        stmtUpdateByPKey.setLong(argIdx++, ContactListId);
        stmtUpdateByPKey.setLong(argIdx++, TenantId);
        stmtUpdateByPKey.setString(argIdx++, Description);
        if (StripDigits != null) {
            stmtUpdateByPKey.setInt(argIdx++, StripDigits.intValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        stmtUpdateByPKey.execute();
        boolean moreResults = true;
        resultSet = null;
        while (resultSet == null) {
            try {
                moreResults = stmtUpdateByPKey.getMoreResults();
            } catch (SQLException e) {
                throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
            }
            if (moreResults) {
                try {
                    resultSet = stmtUpdateByPKey.getResultSet();
                } catch (SQLException e) {
                }
            } else if (-1 == stmtUpdateByPKey.getUpdateCount()) {
                break;
            }
        }
        if (resultSet == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                    "resultSet");
        }
        if (resultSet.next()) {
            CFCrmContactListBuff updatedBuff = unpackContactListResultSetToBuff(resultSet);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredDescription(updatedBuff.getRequiredDescription());
            Buff.setOptionalStripDigits(updatedBuff.getOptionalStripDigits());
            Buff.setRequiredRevision(updatedBuff.getRequiredRevision());
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected a single-record response, " + resultSet.getRow() + " rows selected");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:com.streamsets.pipeline.lib.jdbc.multithread.TableContextUtil.java

private TableContext createCDCTableContext(String schemaName, String tableName, String initalOffset,
        Map<String, Integer> columnToType) throws SQLException, StageException {
    LinkedHashMap<String, Integer> offsetColumnToType = new LinkedHashMap<>();
    Map<String, String> offsetColumnToStartOffset = new HashMap<>();

    if (!Strings.isNullOrEmpty(initalOffset)) {
        offsetColumnToStartOffset.put(MSQueryUtil.CDC_START_LSN, initalOffset);
    }//from w w  w.  j a  va 2 s.com

    offsetColumnToType.put(MSQueryUtil.CDC_START_LSN, Types.VARBINARY);
    offsetColumnToType.put(MSQueryUtil.CDC_SEQVAL, Types.VARBINARY);
    offsetColumnToType.put(MSQueryUtil.CDC_TXN_WINDOW, Types.INTEGER);

    final Map<String, String> offsetAdjustments = new HashMap<>();
    final Map<String, String> offsetColumnMinValues = new HashMap<>();
    final PartitioningMode partitioningMode = TableConfigBean.PARTITIONING_MODE_DEFAULT_VALUE;
    final int maxNumActivePartitions = 0;
    final String extraOffsetColumnConditions = "";

    TableContext tableContext = new TableContext(schemaName, tableName, offsetColumnToType,
            offsetColumnToStartOffset, offsetAdjustments, offsetColumnMinValues,
            TableConfigBean.ENABLE_NON_INCREMENTAL_DEFAULT_VALUE, partitioningMode, maxNumActivePartitions,
            extraOffsetColumnConditions);

    if (columnToType != null) {
        tableContext.setColumnToType(columnToType);
    }

    return tableContext;
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlSchema.java

public boolean isTenantUser(CFAccAuthorization Authorization, long tenantId, String secGroupName) {
    final String S_ProcName = "isTenantUser";
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }//w  ww  .java  2s.  c  o  m
    CallableStatement stmtSecurityCheck = null;
    try {
        final String sql = "exec sp_is_tenant_user ?, ?, ?, ?";
        stmtSecurityCheck = cnx.prepareCall(sql);
        stmtSecurityCheck.registerOutParameter(1, java.sql.Types.INTEGER);
        stmtSecurityCheck.setLong(2, tenantId);
        stmtSecurityCheck.setString(3, secGroupName);
        stmtSecurityCheck.setString(4, 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(), S_ProcName, e);
    } finally {
        if (stmtSecurityCheck != null) {
            try {
                stmtSecurityCheck.close();
            } catch (SQLException e) {
            }
            stmtSecurityCheck = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmMySql.CFCrmMySqlContactListTable.java

public void updateContactList(CFCrmAuthorization Authorization, CFCrmContactListBuff Buff) {
    final String S_ProcName = "updateContactList";
    ResultSet resultSet = null;/*  w  w w. jav  a 2 s .c  om*/
    try {
        long ContactListId = Buff.getRequiredContactListId();
        long TenantId = Buff.getRequiredTenantId();
        String Description = Buff.getRequiredDescription();
        Integer StripDigits = Buff.getOptionalStripDigits();
        int Revision = Buff.getRequiredRevision();
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_update_ctclst( ?, ?, ?, ?, ?, ?" + ", "
                + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )";
        if (stmtUpdateByPKey == null) {
            stmtUpdateByPKey = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtUpdateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtUpdateByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtUpdateByPKey.setString(argIdx++, "CTL");
        stmtUpdateByPKey.setLong(argIdx++, ContactListId);
        stmtUpdateByPKey.setLong(argIdx++, TenantId);
        stmtUpdateByPKey.setString(argIdx++, Description);
        if (StripDigits != null) {
            stmtUpdateByPKey.setInt(argIdx++, StripDigits.intValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        try {
            resultSet = stmtUpdateByPKey.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        if ((resultSet != null) && resultSet.next()) {
            CFCrmContactListBuff updatedBuff = unpackContactListResultSetToBuff(resultSet);
            if ((resultSet != null) && resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
            Buff.setRequiredDescription(updatedBuff.getRequiredDescription());
            Buff.setOptionalStripDigits(updatedBuff.getOptionalStripDigits());
            Buff.setRequiredRevision(updatedBuff.getRequiredRevision());
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected a single-record response, " + resultSet.getRow() + " rows selected");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = 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  www.  ja  va 2  s.c om
    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 Item addWatch(final Watch watch) {
    Item obj = null;/*from  w w w . ja v a  2s.co  m*/

    Connection conn = null;
    CallableStatement stmt = null;
    ResultSet rs = null;

    try {
        conn = _dataSource.getConnection();

        stmt = conn.prepareCall("{call SP_EDITWATCH (?,?,?)}");
        stmt.registerOutParameter(1, Types.INTEGER);
        stmt.setInt(2, watch.getItemUid());
        stmt.setInt(3, watch.getUserUid());

        stmt.execute();
        stmt.close(); // close statement to prevent leak

        stmt = conn.prepareCall("{call SP_GETITEM (?)}");
        stmt.setInt(1, watch.getItemUid());

        rs = stmt.executeQuery();

        if (rs.next()) {
            ItemBuilder builder = Item.newBuilder().setUid(rs.getInt("UID"))
                    .setAuctionUid(rs.getInt("AUCTIONUID")).setItemNumber(rs.getString("ITEMNUMBER"))
                    .setName(rs.getString("NAME")).sertCurPrice(rs.getDouble("CURPRICE"))
                    .setWinner(rs.getString("WINNER")).setBidCount(rs.getInt("BIDCOUNT"))
                    .setWatchCount(rs.getInt("WATCHCOUNT"));

            obj = builder.build();
        }
    } catch (SQLException e) {
        LOG.error(Throwables.getStackTraceAsString(e));
    } finally {
        DbUtils.closeQuietly(conn, stmt, rs);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("WATCH [method:{} result:{}]",
                new Object[] { "add", obj != null ? obj.toString() : "[error]" });
    }

    return obj;
}