List of usage examples for java.sql PreparedStatement setInt
void setInt(int parameterIndex, int x) throws SQLException;
int
value. From source file:las.DBConnector.java
public static void insertTransactionIntoTable(Member member, Item item) throws SQLException { String data = "INSERT INTO TRANSACTIONS(MEMBER_ID,ITEM_ID)" + "Values (?,?)"; PreparedStatement pt = conn.prepareStatement(data); pt.setInt(1, member.getID()); pt.setInt(2, item.getItemID());/*from ww w . ja va 2 s .c o m*/ pt.executeUpdate(); }
From source file:las.DBConnector.java
public static void removeTransactionFromTable(Transaction transaction) throws SQLException { String data = "DELETE FROM TRANSACTIONS WHERE MEMBER_ID = ?" + "AND ITEM_ID = ?"; PreparedStatement pt = conn.prepareStatement(data); pt.setInt(1, transaction.getMemberID()); pt.setInt(2, transaction.getItemID()); pt.executeUpdate();//from ww w . j av a 2 s .c om }
From source file:las.DBConnector.java
public static void incrementAmountLeft(Item item) throws SQLException { String data = "UPDATE ITEMS SET AMOUNTLEFT = ? WHERE ITEM_ID = ?"; PreparedStatement pt = conn.prepareStatement(data); pt.setInt(1, (item.getAmountLeft() + 1)); pt.setInt(2, item.getItemID());/*from w ww . ja v a 2 s.c o m*/ pt.executeUpdate(); }
From source file:las.DBConnector.java
public static void decrementAmountLeft(Item item) throws SQLException { String data = "UPDATE ITEMS SET AMOUNTLEFT = ? WHERE ITEM_ID = ?"; PreparedStatement pt = conn.prepareStatement(data); pt.setInt(1, (item.getAmountLeft() - 1)); pt.setInt(2, item.getItemID());/*from w ww . j a v a2s .co m*/ pt.executeUpdate(); }
From source file:las.DBConnector.java
public static void insertMemberIntoTable(Member member) throws SQLException { String data = "INSERT INTO MEMBERS(MEMBER_ID,NAME,EMAIL,PRIVILEGE,ISSTAFF)" + "Values (?,?,?,?,?)"; PreparedStatement pt = conn.prepareStatement(data); pt.setInt(1, member.getID()); pt.setString(2, member.getName());//www.j a va2 s.c o m pt.setString(3, member.getEmail()); pt.setString(4, member.getPrivilege()); pt.setBoolean(5, member.isIsStaff()); pt.executeUpdate(); }
From source file:las.DBConnector.java
public static void insertTransactionIntoTable(Transaction transaction) throws SQLException { String data = "INSERT INTO TRANSACTIONS(MEMBER_ID, ITEM_ID)" + "Values (?,?)"; PreparedStatement pt = conn.prepareStatement(data); pt.setInt(1, transaction.getMemberID()); pt.setInt(2, transaction.getItemID()); try {/*from ww w . j a v a 2 s.com*/ pt.executeUpdate(); } catch (Exception DerbySQLIntegrityConstraintViolationException) { JOptionPane.showMessageDialog(null, "Cannot Issue an item a member already owns!"); } }
From source file:com.app.dao.SearchQueryDAO.java
private static void _populateAddSearchQueryPreparedStatement(PreparedStatement preparedStatement, SearchQuery searchQuery) throws SQLException { preparedStatement.setInt(1, searchQuery.getUserId()); preparedStatement.setString(2, searchQuery.getKeywords()); preparedStatement.setString(3, searchQuery.getCategoryId()); preparedStatement.setString(4, searchQuery.getSubcategoryId()); preparedStatement.setBoolean(5, searchQuery.isSearchDescription()); preparedStatement.setBoolean(6, searchQuery.isFreeShippingOnly()); preparedStatement.setBoolean(7, searchQuery.isNewCondition()); preparedStatement.setBoolean(8, searchQuery.isUsedCondition()); preparedStatement.setBoolean(9, searchQuery.isUnspecifiedCondition()); preparedStatement.setBoolean(10, searchQuery.isAuctionListing()); preparedStatement.setBoolean(11, searchQuery.isFixedPriceListing()); preparedStatement.setDouble(12, searchQuery.getMaxPrice()); preparedStatement.setDouble(13, searchQuery.getMinPrice()); preparedStatement.setString(14, searchQuery.getGlobalId()); preparedStatement.setBoolean(15, searchQuery.isActive()); }
From source file:fll.db.NonNumericNominees.java
/** * Get all subjective categories know for the specified tournament. * //from ww w .j av a2s .c o m * @throws SQLException */ public static Set<String> getCategories(final Connection connection, final int tournamentId) throws SQLException { final Set<String> result = new HashSet<>(); PreparedStatement get = null; ResultSet rs = null; try { get = connection .prepareStatement("SELECT DISTINCT category FROM non_numeric_nominees WHERE tournament = ?"); get.setInt(1, tournamentId); rs = get.executeQuery(); while (rs.next()) { final String category = rs.getString(1); result.add(category); } } finally { SQLFunctions.close(rs); SQLFunctions.close(get); } return result; }
From source file:fll.db.NonNumericNominees.java
/** * Clear the nominees for the specified category at the tournament. * /* www.j av a2 s . c o m*/ * @param connection database connection * @param tournamentId the tournament * @param category the category * @throws SQLException */ public static void clearNominees(final Connection connection, final int tournamentId, final String category) throws SQLException { PreparedStatement delete = null; try { delete = connection.prepareStatement("DELETE FROM non_numeric_nominees"// + " WHERE tournament = ?"// + " AND category = ?"); delete.setInt(1, tournamentId); delete.setString(2, category); delete.executeUpdate(); } finally { SQLFunctions.close(delete); } }
From source file:net.codjo.dataprocess.server.treatmenthelper.TreatmentHelper.java
public static void insertRepository(Connection con, int repositoryId, String repositoryName) throws SQLException { PreparedStatement pStmt = con .prepareStatement("insert into PM_REPOSITORY (REPOSITORY_ID, REPOSITORY_NAME) values (?, ?)"); try {//from w w w . j a v a 2 s . c o m pStmt.setInt(1, repositoryId); pStmt.setString(2, repositoryName); pStmt.executeUpdate(); } finally { pStmt.close(); } }