List of usage examples for java.sql PreparedStatement setBoolean
void setBoolean(int parameterIndex, boolean x) throws SQLException;
boolean
value. From source file:org.apache.stratos.status.monitor.agent.internal.core.MySQLConnector.java
/** * Inserts into the heartbeats table// ww w . j a va 2 s . c o m * * @param serviceID serviceId * @param status - status of the service * @throws SQLException, if inserting the stats failed */ public static void insertStats(int serviceID, Boolean status) throws SQLException { String sql = StatusMonitorConstants.INSERT_STAT_SQL; PreparedStatement pstmt = conn.prepareStatement(sql); try { pstmt.setString(1, null); pstmt.setInt(2, serviceID); pstmt.setBoolean(3, status); pstmt.setString(4, null); pstmt.executeUpdate(); } catch (SQLException e) { String msg = "Inserting stats failed"; log.error(msg, e); throw new SQLException(msg, e); } finally { pstmt.close(); } }
From source file:org.sonar.db.measure.ProjectMeasuresIndexerIterator.java
private static PreparedStatement createProjectsStatement(DbSession session, @Nullable String projectUuid) { try {// ww w . java 2s.c om String sql = SQL_PROJECTS; sql += projectUuid == null ? "" : PROJECT_FILTER; PreparedStatement stmt = session.getConnection().prepareStatement(sql); stmt.setBoolean(1, true); stmt.setBoolean(2, true); stmt.setString(3, Scopes.PROJECT); stmt.setString(4, Qualifiers.PROJECT); if (projectUuid != null) { stmt.setString(5, projectUuid); } return stmt; } catch (SQLException e) { throw new IllegalStateException("Fail to prepare SQL request to select all project measures", e); } }
From source file:org.sonar.db.measure.ProjectMeasuresIndexerIterator.java
private static PreparedStatement createMetricsStatement(DbSession session) throws SQLException { PreparedStatement stmt = session.getConnection().prepareStatement(SQL_METRICS); stmt.setString(1, NCLOC_LANGUAGE_DISTRIBUTION_KEY); stmt.setBoolean(2, true); return stmt;//from w ww . jav a 2 s.c o m }
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());/*from www .jav a 2 s .com*/ pt.setString(2, member.getName()); pt.setString(3, member.getEmail()); pt.setString(4, member.getPrivilege()); pt.setBoolean(5, member.isIsStaff()); pt.executeUpdate(); }
From source file:org.bml.util.sql.DBUtil.java
/** * * @param ps/* w ww . ja va 2s . c o m*/ * @param keyName * @param fieldId * @param map * @param remove * @throws SQLException */ public static void setBoolean(PreparedStatement ps, String keyName, int fieldId, Map<String, String> map, boolean remove) throws SQLException { String val = map.get(keyName); if (remove) { map.remove(keyName); } if (val == null) { ps.setBoolean(fieldId, false); return; } if (val.isEmpty()) { ps.setBoolean(fieldId, false); } else { ps.setBoolean(fieldId, Boolean.parseBoolean(val)); } }
From source file:org.mapbuilderfreq.FrequencyMapClient.java
public static void setFreshStart(boolean freshStart) { try {/* w w w .j a v a 2 s . c o m*/ String updateQuery = "Update public.\"SysParams\" SET \"FreshStart\" = ? WHERE \"Id\" = 2;"; PreparedStatement preparedStatement = db.prepareStatement(updateQuery); preparedStatement.setBoolean(1, freshStart); preparedStatement.executeUpdate(); } catch (SQLException ex) { System.err.println("FreshStart updating failed..."); System.err.println(ex); System.exit(0); } }
From source file:com.concursive.connect.web.webdav.WebdavManager.java
/** * Gets the webdavPassword attribute of the WebdavManager object * * @param db Description of the Parameter * @param username Description of the Parameter * @return The webdavPassword value//from w w w.jav a2 s .com * @throws SQLException Description of the Exception */ public static String getWebdavPassword(Connection db, String username) throws SQLException { String password = ""; PreparedStatement pst = db.prepareStatement( "SELECT webdav_password " + "FROM users " + "WHERE username = ? " + "AND enabled = ? "); pst.setString(1, username); pst.setBoolean(2, true); ResultSet rs = pst.executeQuery(); if (rs.next()) { password = rs.getString("webdav_password"); } rs.close(); pst.close(); return password; }
From source file:com.app.dao.SearchQueryDAO.java
private static void _populateUpdateSearchQueryPreparedStatement(PreparedStatement preparedStatement, SearchQuery searchQuery, int userId) throws SQLException { preparedStatement.setString(1, searchQuery.getKeywords()); preparedStatement.setString(2, searchQuery.getCategoryId()); preparedStatement.setString(3, searchQuery.getSubcategoryId()); preparedStatement.setBoolean(4, searchQuery.isSearchDescription()); preparedStatement.setBoolean(5, searchQuery.isFreeShippingOnly()); preparedStatement.setBoolean(6, searchQuery.isNewCondition()); preparedStatement.setBoolean(7, searchQuery.isUsedCondition()); preparedStatement.setBoolean(8, searchQuery.isUnspecifiedCondition()); preparedStatement.setBoolean(9, searchQuery.isAuctionListing()); preparedStatement.setBoolean(10, searchQuery.isFixedPriceListing()); preparedStatement.setDouble(11, searchQuery.getMaxPrice()); preparedStatement.setDouble(12, searchQuery.getMinPrice()); preparedStatement.setString(13, searchQuery.getGlobalId()); preparedStatement.setBoolean(14, searchQuery.isActive()); preparedStatement.setInt(15, searchQuery.getSearchQueryId()); preparedStatement.setInt(16, userId); }
From source file:com.concursive.connect.web.webdav.WebdavManager.java
public static int validateUser(Connection db, HttpServletRequest req) throws Exception { String argHeader = req.getHeader("Authorization"); HashMap params = getAuthenticationParams(argHeader); String username = (String) params.get("username"); if (md5Helper == null) { md5Helper = MessageDigest.getInstance("MD5"); }/*from ww w .ja va2s .c o m*/ int userId = -1; String password = null; PreparedStatement pst = db.prepareStatement( "SELECT user_id, webdav_password " + "FROM users " + "WHERE username = ? " + "AND enabled = ? "); pst.setString(1, username); pst.setBoolean(2, true); ResultSet rs = pst.executeQuery(); if (rs.next()) { userId = rs.getInt("user_id"); password = rs.getString("webdav_password"); } rs.close(); pst.close(); if (userId == -1) { return userId; } String method = req.getMethod(); String uri = (String) params.get("uri"); String a2 = MD5Encoder.encode(md5Helper.digest((method + ":" + uri).getBytes())); String digest = MD5Encoder .encode(md5Helper.digest((password + ":" + params.get("nonce") + ":" + a2).getBytes())); if (!digest.equals(params.get("response"))) { userId = -1; } return userId; }
From source file:com.concursive.connect.web.modules.setup.utils.SetupUtils.java
/** * Determines if there is an administrative user configured in the database * * @param db/*from w ww . j a va 2 s . c om*/ * @return */ public static boolean isAdminInstalled(Connection db) { int count = -1; try { PreparedStatement pst = db.prepareStatement( "SELECT count(*) AS recordcount " + "FROM users " + "WHERE access_admin = ? "); pst.setBoolean(1, true); ResultSet rs = pst.executeQuery(); rs.next(); count = rs.getInt("recordcount"); rs.close(); pst.close(); } catch (Exception e) { } return count > 0; }