List of usage examples for java.sql PreparedStatement setInt
void setInt(int parameterIndex, int x) throws SQLException;
int
value. From source file:fll.web.playoff.Playoff.java
/** * Get max performance run number for playoff division. * //from www .j a v a 2 s. com * @param playoffDivision the division to check * @return performance round, -1 if there are no playoff rounds for this * division */ public static int getMaxPerformanceRound(final Connection connection, final int currentTournament, final String playoffDivision) throws SQLException { PreparedStatement maxPrep = null; ResultSet max = null; try { maxPrep = connection.prepareStatement("SELECT MAX(run_number) FROM PlayoffData WHERE" // + " event_division = ? AND tournament = ?"); maxPrep.setString(1, playoffDivision); maxPrep.setInt(2, currentTournament); max = maxPrep.executeQuery(); if (max.next()) { final int runNumber = max.getInt(1); return runNumber; } else { return -1; } } finally { SQLFunctions.close(max); SQLFunctions.close(maxPrep); } }
From source file:com.imagelake.control.CreditsDAOImp.java
@Override public int getCredit(int subid) { int i = 0;/*w w w . j a va 2s . co m*/ try { String sql = "SELECT credits FROM credits WHERE credit_id=?"; PreparedStatement ps = DBFactory.getConnection().prepareStatement(sql); ps.setInt(1, subid); ResultSet rs = ps.executeQuery(); if (rs.next()) { i = rs.getInt(1); } } catch (Exception e) { e.printStackTrace(); } return i; }
From source file:cai.flow.packets.V8_FlowPrefix.java
void fill_specific(PreparedStatement add_raw_stm) throws SQLException { add_raw_stm.setString(13, Util.str_addr(src_prefix)); add_raw_stm.setString(14, Util.str_addr(dst_prefix)); add_raw_stm.setInt(15, (int) src_mask); add_raw_stm.setInt(16, (int) dst_mask); add_raw_stm.setInt(17, (int) src_as); add_raw_stm.setInt(18, (int) dst_as); add_raw_stm.setInt(19, (int) input); add_raw_stm.setInt(20, (int) output); add_raw_stm.setString(21, Params.getCurrentTime()); }
From source file:com.adanac.module.blog.dao.AnswerDao.java
public List<Map<String, String>> getAnswers(final Integer questionId) { return execute(new Operation<List<Map<String, String>>>() { @Override/*from www . ja v a 2s . c o m*/ public List<Map<String, String>> doInConnection(Connection connection) { List<Map<String, String>> comments = new ArrayList<Map<String, String>>(); try { PreparedStatement statement = connection.prepareStatement( "select * from answers where question_id=? order by good_times DESC , answer_date ASC "); statement.setInt(1, questionId); ResultSet resultSet = statement.executeQuery(); while (resultSet.next()) { comments.add(transfer(resultSet, null)); } } catch (SQLException e) { error("get answers for question[" + questionId + "] failed ...", e); } return comments; } }); }
From source file:com.imagelake.control.CreditsDAOImp.java
public boolean checkSliceImage(int cid, int typeid) { boolean ok = false; try {/*from w ww. j av a 2s .c o m*/ String sql = "SELECT * FROM slice_image WHERE credit_id=? AND type_id=? AND status='1'"; PreparedStatement ps = DBFactory.getConnection().prepareStatement(sql); ps.setInt(1, cid); ps.setInt(2, typeid); ResultSet rs = ps.executeQuery(); if (rs.next()) { ok = true; } } catch (Exception e) { e.printStackTrace(); } return ok; }
From source file:Crawler.CrawlerClass.java
public void InsertToIndexDb(DBConnection Conn, String url, String[] Keywords) throws SQLException, IOException { String sql = "select * from contentdb where URL = '" + url + "'"; ResultSet rs = Conn.executeStatement(sql); if (rs.next()) { //store the URL to database to avoid parsing again int ID = rs.getInt("ID"); sql = "INSERT INTO `keyworddb`(`ID`, `Keyword`) " + "VALUES(?,?);"; PreparedStatement stmt = Conn.conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); for (String words : Keywords) { stmt.setInt(1, ID); stmt.setString(2, words.trim()); }//from w ww. ja va 2 s . c o m stmt.execute(); } }
From source file:com.ewcms.component.online.dao.AdvisorDAO.java
public int add(final Advisor vo) { final String sql = "Insert Into plugin_online_advisory " + "(username,name,title,content,organ_id,matter_id,ip) Values " + "(?,?,?,?,?,?,?)"; jdbcTemplate.update(new PreparedStatementCreator() { @Override/*from w ww .j a v a 2 s . c o m*/ public PreparedStatement createPreparedStatement(Connection con) throws SQLException { PreparedStatement ps = con.prepareStatement(sql); ps.setString(1, vo.getUsername()); ps.setString(2, vo.getName()); ps.setString(3, vo.getTitle()); ps.setString(4, vo.getContent()); ps.setInt(5, vo.getOrganId()); ps.setInt(6, vo.getMatterId()); ps.setString(7, vo.getIp()); return ps; } }); return jdbcTemplate.queryForInt("select currval('seq_plugin_online_advisory_id')"); }
From source file:oobbit.orm.LinkConnections.java
public int add(LinkConnection linkConnection) throws SQLException, NotValidLinkConnectionException { verifier.verify(linkConnection); // first verify then add if successful PreparedStatement statement = getConnection().prepareStatement( "INSERT INTO `oobbit`.`connections` (`source_link_id`, `destination_link_id`, `title`, `creator`, `create_time`, `edit_time`) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);"); statement.setInt(1, linkConnection.getSourceLinkId()); statement.setInt(2, linkConnection.getDestinationLinkId()); statement.setString(3, linkConnection.getTitle()); statement.setInt(4, linkConnection.getCreator()); statement.executeUpdate();// w w w .j av a 2 s . c o m statement.close(); return linkConnection.getSourceLinkId(); }
From source file:com.imagelake.control.CreditsDAOImp.java
@Override public boolean insertCredits(Credits c) { boolean ok = false; try {/*from w w w . jav a 2 s . c o m*/ String sql = "INSERT INTO credits(credits,size,width,height,state) VALUE(?,?,?,?,?)"; PreparedStatement ps = DBFactory.getConnection().prepareStatement(sql); ps.setInt(1, c.getCredits()); ps.setString(2, c.getSize()); ps.setInt(3, c.getWidth()); ps.setInt(4, c.getHeight()); ps.setInt(5, c.getState()); int i = ps.executeUpdate(); if (i > 0) { ok = true; } } catch (Exception e) { e.printStackTrace(); } return ok; }
From source file:oobbit.orm.Links.java
public List<Link> getAll(int limit, String category) throws SQLException { PreparedStatement statement = getConnection().prepareStatement( "SELECT * FROM oobbit.links AS q1 LEFT JOIN users AS q2 ON q1.creator = q2.user_id WHERE q1.category = ? LIMIT ?;"); statement.setString(1, category);/*from www . ja v a 2 s.com*/ statement.setInt(2, limit); return parseResults(statement.executeQuery()); }