List of usage examples for java.sql PreparedStatement setInt
void setInt(int parameterIndex, int x) throws SQLException;
int
value. From source file:oobbit.orm.Comments.java
/** * Removes a single comment. Please note that this is not called when a Link * is removed, the database handles the deletion of associated comments by * itself via CASCADE.//w ww . j a v a2 s .c o m * * @param commentId * * @throws SQLException PreparedStatement failed to execute */ public void remove(int commentId) throws SQLException { PreparedStatement statement = getConnection() .prepareStatement("DELETE FROM `oobbit`.`comments` WHERE `comments`.`comment_id` = ?"); statement.setInt(1, commentId); statement.executeUpdate(); statement.close(); }
From source file:net.freechoice.model.orm.Map_Transaction.java
@Override public PreparedStatementCreator createUpdate(final FC_Transaction entity) { return new PreparedStatementCreator() { @Override/*from w w w . j av a 2 s . co m*/ public PreparedStatement createPreparedStatement(Connection con) throws SQLException { PreparedStatement ps = con.prepareStatement("update FC_Transaction" + " set id_account_ = ?," + " amount = ?, " + " comment = ? " + "where id = " + entity.id); ps.setInt(1, entity.id_account_); ps.setBigDecimal(2, entity.amount); ps.setString(3, entity.comment); return ps; } }; }
From source file:fll.web.playoff.Playoff.java
/** * Create a playoff bracket.//w w w . jav a2 s . c o m * Does not check if the bracket already exists. */ public static void createPlayoffBracket(final Connection connection, final int tournamentId, final String bracketName, final List<Integer> teamNumbers) throws SQLException { PreparedStatement prep = null; try { prep = connection.prepareStatement( "INSERT INTO playoff_bracket_teams (tournament_id, bracket_name, team_number) VALUES(?, ?, ?)"); prep.setInt(1, tournamentId); prep.setString(2, bracketName); for (final Integer teamNumber : teamNumbers) { prep.setInt(3, teamNumber); prep.executeUpdate(); } } finally { SQLFunctions.close(prep); } }
From source file:fp4f.floorplans.DatabaseLayer.java
ArrayList<FloorItem> getFloors(int houseId) { ArrayList<FloorItem> floors = new ArrayList<FloorItem>(); try {/*from w ww . j a v a 2 s.c o m*/ PreparedStatement getter = con .prepareStatement("select * from floors where house = ? order by level desc"); getter.setInt(1, houseId); ResultSet rs = getter.executeQuery(); while (rs.next()) { FloorItem floor = new FloorItem(); floor.Id = rs.getInt("id"); floor.HouseId = houseId; floor.Level = rs.getInt("level"); floor.FloorPlan = rs.getString("image"); floor.load(); floors.add(floor); } } catch (Exception ex) { System.out.println(ex); } return floors; }
From source file:com.products.ProductResource.java
@DELETE @Path("{id}") @Consumes(MediaType.APPLICATION_JSON)/*from w w w . j av a 2 s. c o m*/ @Produces(MediaType.TEXT_PLAIN) public String deleteProduct(@PathParam("id") int id) throws SQLException { if (co == null) { return "not connected"; } else { String query = "DELETE FROM product WHERE product_id = ?"; PreparedStatement stmt = co.prepareStatement(query); stmt.setInt(1, id); stmt.executeUpdate(); return "The specified row is deleted"; } }
From source file:edu.cmu.lti.oaqa.openqa.hello.eval.passage.PassageMAPEvalPersistenceProvider.java
@Override public void deletePassageMeasureEval(final ExperimentKey experiment) { String insert = getDeletePassageMeasureEval(); DataStoreImpl.getInstance().jdbcTemplate().update(insert, new PreparedStatementSetter() { public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, experiment.getExperiment()); ps.setInt(2, experiment.getStage()); }// ww w.j a v a2s. co m }); }
From source file:oobbit.orm.LinkConnections.java
public LinkConnection getOne(int sourceId, int destinationId) throws SQLException, NothingWasFoundException { PreparedStatement statement = getConnection().prepareStatement( "SELECT * FROM `connections` WHERE `source_link_id` = ? AND `destination_link_id` = ?;"); statement.setInt(1, sourceId); statement.setInt(2, destinationId);//from www .j a va 2 s .co m ResultSet query = statement.executeQuery(); if (query.next()) { LinkConnection connection = new LinkConnection(); connection.parse(query); return connection; } throw new NothingWasFoundException("No connection found between given links."); }
From source file:oobbit.orm.Links.java
public void remove(int linkId) throws SQLException { PreparedStatement statement = getConnection() .prepareStatement("DELETE FROM `oobbit`.`links` WHERE `links`.`link_id` = ?;"); statement.setInt(1, linkId); statement.executeUpdate();/*w w w . j a va 2 s . c o m*/ statement.close(); }
From source file:com.Assignment4.Assign.java
@DELETE @Path("{id}") @Consumes(MediaType.APPLICATION_JSON)/*from w ww.ja v a2 s. com*/ @Produces(MediaType.TEXT_PLAIN) public String deleteProduct(@PathParam("id") int id) throws SQLException { if (connected == null) { return "not connected"; } else { String query = "DELETE FROM product WHERE product_id = ?"; PreparedStatement pstmt = connected.prepareStatement(query); pstmt.setInt(1, id); pstmt.executeUpdate(); return "The specified row is deleted"; } }
From source file:com.Assignment4.Prod.java
@DELETE @Path("{id}") @Consumes(MediaType.APPLICATION_JSON)/*from w ww . ja v a 2 s. c o m*/ @Produces(MediaType.TEXT_PLAIN) public String deleteProduct(@PathParam("id") int id) throws SQLException { if (connect == null) { return "not connected"; } else { String query = "DELETE FROM product WHERE product_id = ?"; PreparedStatement prepstmt = connect.prepareStatement(query); prepstmt.setInt(1, id); prepstmt.executeUpdate(); return "The specified row is deleted"; } }