List of usage examples for java.sql CallableStatement setInt
void setInt(String parameterName, int x) throws SQLException;
int
value. From source file:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java
@Override public List<Fund> getFundsByUser(final int userUid) { List<Fund> objs = Lists.newArrayList(); Connection conn = null;//from w ww.j a v a 2 s . c o m CallableStatement stmt = null; ResultSet rs = null; try { conn = _dataSource.getConnection(); stmt = conn.prepareCall("{call SP_GETFUNDSBYUSER (?)}"); stmt.setInt(1, userUid); rs = stmt.executeQuery(); while (rs.next()) { FundBuilder builder = Fund.newBuilder().setUid(rs.getInt("UID")).setUserUid(rs.getInt("USERUID")) .setBidPrice(rs.getDouble("FUNDPRICE")).setBidDate(rs.getDate("FUNDDATE").getTime()); objs.add(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[] { "get", objs.size() }); } return ImmutableList.copyOf(objs); }
From source file:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java
@Override public Item getItem(final int uid) { Item obj = null;/*from www . j a v a2 s . c om*/ Connection conn = null; CallableStatement stmt = null; ResultSet rs = null; try { conn = _dataSource.getConnection(); stmt = conn.prepareCall("{call SP_GETITEM (?)}"); stmt.setInt(1, uid); 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")).setDescription(rs.getString("DESCRIPTION")) .setCategory(rs.getString("CATEGORY")).setSeller(rs.getString("SELLER")) .setValPrice(rs.getDouble("VALPRICE")).setMinPrice(rs.getDouble("MINPRICE")) .setIncPrice(rs.getDouble("INCPRICE")).sertCurPrice(rs.getDouble("CURPRICE")) .setWinner(rs.getString("WINNER")).setBidCount(rs.getInt("BIDCOUNT")) .setWatchCount(rs.getInt("WATCHCOUNT")).setUrl(rs.getString("URL")) .setMultiSale(rs.getBoolean("MULTI")); obj = builder.build(); } } catch (SQLException e) { LOG.error(Throwables.getStackTraceAsString(e)); } finally { DbUtils.closeQuietly(conn, stmt, rs); } if (LOG.isDebugEnabled()) { LOG.debug("ITEM [method:{} result:{}]", new Object[] { "get", obj != null ? obj.toString() : "[error]" }); } return obj; }
From source file:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java
@Override public List<Item> getItemsUpdatesOnly(final int auctionUid) { List<Item> objs = Lists.newArrayList(); Connection conn = null;// ww w. ja va 2s. c om CallableStatement stmt = null; ResultSet rs = null; try { conn = _dataSource.getConnection(); stmt = conn.prepareCall("{call SP_GETITEMUPDATES (?)}"); stmt.setInt(1, auctionUid); rs = stmt.executeQuery(); while (rs.next()) { ItemBuilder builder = Item.newBuilder().setUid(rs.getInt("UID")) .setAuctionUid(rs.getInt("AUCTIONUID")).setItemNumber(rs.getString("ITEMNUMBER")) .sertCurPrice(rs.getDouble("CURPRICE")).setWinner(rs.getString("WINNER")) .setBidCount(rs.getInt("BIDCOUNT")).setWatchCount(rs.getInt("WATCHCOUNT")); objs.add(builder.build()); } } catch (SQLException e) { LOG.error(Throwables.getStackTraceAsString(e)); } finally { DbUtils.closeQuietly(conn, stmt, rs); } if (LOG.isDebugEnabled()) { LOG.debug("ITEM [method:{} result:{}]", new Object[] { "get", objs.size() }); } return ImmutableList.copyOf(objs); }
From source file:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java
@Override public List<Watch> getWatchesByItem(final int itemUid) { List<Watch> objs = Lists.newArrayList(); Connection conn = null;// w w w. jav a 2 s . co m CallableStatement stmt = null; ResultSet rs = null; try { conn = _dataSource.getConnection(); stmt = conn.prepareCall("{call SP_GETWATCHESBYITEM (?)}"); stmt.setInt(1, itemUid); rs = stmt.executeQuery(); while (rs.next()) { WatchBuilder builder = Watch.newBuilder().setUid(rs.getInt("UID")).setUserUid(rs.getInt("USERUID")) .setItemUid(rs.getInt("ITEMUID")); objs.add(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[] { "get", objs.size() }); } return ImmutableList.copyOf(objs); }
From source file:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java
@Override public List<Watch> getWatchesByUser(final int userUid) { List<Watch> objs = Lists.newArrayList(); Connection conn = null;//from ww w . ja v a2 s . c o m CallableStatement stmt = null; ResultSet rs = null; try { conn = _dataSource.getConnection(); stmt = conn.prepareCall("{call SP_GETWATCHESBYUSER (?)}"); stmt.setInt(1, userUid); rs = stmt.executeQuery(); while (rs.next()) { WatchBuilder builder = Watch.newBuilder().setUid(rs.getInt("UID")).setUserUid(rs.getInt("USERUID")) .setItemUid(rs.getInt("ITEMUID")); objs.add(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[] { "get", objs.size() }); } return ImmutableList.copyOf(objs); }
From source file:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java
@Override public Bid getMaxBidByItem(final int itemUid) { Bid obj = null;//from ww w . j av a 2 s .c om Connection conn = null; CallableStatement stmt = null; ResultSet rs = null; try { conn = _dataSource.getConnection(); stmt = conn.prepareCall("{call SP_GETMAXBIDBYITEM (?)}"); stmt.setInt(1, itemUid); rs = stmt.executeQuery(); if (rs.next()) { BidBuilder builder = Bid.newBuilder().setUid(rs.getInt("UID")).setItemUid(rs.getInt("ITEMUID")) .setUserUid(rs.getInt("USERUID")).setBidPrice(rs.getDouble("BIDPRICE")) .setBidDate(rs.getDate("BIDDATE").getTime()); obj = builder.build(); } } catch (SQLException e) { LOG.error(Throwables.getStackTraceAsString(e)); } finally { DbUtils.closeQuietly(conn, stmt, rs); } if (LOG.isDebugEnabled()) { LOG.debug("BID [method:{} result:{}]", new Object[] { "get", obj != null ? obj.toString() : "[error]" }); } return obj; }
From source file:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java
@Override public List<Device> getDevicesByUser(final int userUid) { List<Device> objs = Lists.newArrayList(); Connection conn = null;// w ww . jav a 2s.c o m CallableStatement stmt = null; ResultSet rs = null; try { conn = _dataSource.getConnection(); stmt = conn.prepareCall("{call SP_GETDEVICESFORUSER (?)}"); stmt.setInt(1, userUid); rs = stmt.executeQuery(); while (rs.next()) { DeviceBuilder builder = Device.newBuilder().setUid(rs.getInt("UID")) .setUserUid(rs.getInt("USERUID")).setDeviceId(rs.getString("DEVICEID")) .setDeviceType(rs.getString("DEVICETYPE")); objs.add(builder.build()); } } catch (SQLException e) { LOG.error(Throwables.getStackTraceAsString(e)); } finally { DbUtils.closeQuietly(conn, stmt, rs); } if (LOG.isDebugEnabled()) { LOG.debug("DEVICE [method:{} result:{}]", new Object[] { "get", objs.size() }); } return ImmutableList.copyOf(objs); }
From source file:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java
@Override public Auction getAuction(final int uid) { Auction obj = null;/* w w w. ja va2 s.c om*/ Connection conn = null; CallableStatement stmt = null; ResultSet rs = null; try { conn = _dataSource.getConnection(); stmt = conn.prepareCall("{call SP_GETAUCTION (?)}"); stmt.setInt(1, uid); rs = stmt.executeQuery(); if (rs.next()) { AuctionBuilder builder = Auction.newBuilder().setUid(rs.getInt("UID")) .setName(rs.getString("NAME")); Date startdate = rs.getDate("STARTDATE"); if (startdate != null) { builder.setStartDate(startdate.getTime()); } Date enddate = rs.getDate("ENDDATE"); if (enddate != null) { builder.setEndDate(enddate.getTime()); } builder.setLogoUrl(rs.getString("LOGOURL")); builder.setColor(rs.getString("COLOR")); obj = builder.build(); } } catch (SQLException e) { LOG.error(Throwables.getStackTraceAsString(e)); } finally { DbUtils.closeQuietly(conn, stmt, rs); } if (LOG.isDebugEnabled()) { LOG.debug("AUCTION [method:{} result:{}]", new Object[] { "get", obj != null ? obj.toString() : "[error]" }); } return obj; }
From source file:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java
@Override public List<Category> getCategories(final int auctionUid, final int start, final int length, final String sort, final String dir) { List<Category> objs = Lists.newArrayList(); Connection conn = null;/* w w w . j a v a 2 s . c om*/ CallableStatement stmt = null; ResultSet rs = null; try { conn = _dataSource.getConnection(); stmt = conn.prepareCall("{call SP_GETCATEGORIES (?,?,?,?,?)}"); stmt.setInt(1, auctionUid); stmt.setInt(2, start); stmt.setInt(3, length); stmt.setString(4, sort); stmt.setString(5, dir); rs = stmt.executeQuery(); while (rs.next()) { CategoryBuilder builder = Category.newBuilder().setUid(rs.getInt("UID")) .setAuctionUid(rs.getInt("AUCTIONUID")).setName(rs.getString("NAME")); objs.add(builder.build()); } } catch (SQLException e) { LOG.error(Throwables.getStackTraceAsString(e)); } finally { DbUtils.closeQuietly(conn, stmt, rs); } if (LOG.isDebugEnabled()) { LOG.debug("CATEGORY [method:{} result:{}]", new Object[] { "get", objs.size() }); } return ImmutableList.copyOf(objs); }
From source file:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java
@Override public List<User> getUsers(final int auctionUid, final int start, final int length, final String sort, final String dir) { List<User> objs = Lists.newArrayList(); Connection conn = null;/*from ww w. j a va 2s . co m*/ CallableStatement stmt = null; ResultSet rs = null; try { conn = _dataSource.getConnection(); stmt = conn.prepareCall("{call SP_GETUSERS (?,?,?,?,?)}"); stmt.setInt(1, auctionUid); stmt.setInt(2, start); stmt.setInt(3, length); stmt.setString(4, sort); stmt.setString(5, dir); rs = stmt.executeQuery(); while (rs.next()) { UserBuilder builder = User.newBuilder().setUid(rs.getInt("UID")) .setAuctionUid(rs.getInt("AUCTIONUID")).setBidderNumber(rs.getString("BIDDERNUMBER")) .setFirstName(rs.getString("FIRSTNAME")).setLastName(rs.getString("LASTNAME")) .setRole(Roles.getId(rs.getInt("ROLE"))); User obj = builder.build(); obj.setPasswordHash(rs.getString("PASSWORDHASH")); objs.add(obj); } } catch (SQLException e) { LOG.error(Throwables.getStackTraceAsString(e)); } finally { DbUtils.closeQuietly(conn, stmt, rs); } if (LOG.isDebugEnabled()) { LOG.debug("USER [method:{} result:{}]", new Object[] { "get", objs.size() }); } return ImmutableList.copyOf(objs); }