List of usage examples for java.sql ResultSet getBoolean
boolean getBoolean(String columnLabel) throws SQLException;
ResultSet
object as a boolean
in the Java programming language. From source file:com.nabla.dc.server.xml.settings.XmlUser.java
public XmlUser(final ResultSet rs) throws SQLException { name = new XmlUserName(rs.getString(2)); password = new XmlUserPassword("password"); // DO NOT reveal password here!!! active = rs.getBoolean(3); load(rs.getStatement().getConnection(), rs.getInt(1)); }
From source file:com.splicemachine.derby.impl.sql.execute.operations.CallStatementOperationIT.java
@Test public void testCallSysSchemas() throws Exception { methodWatcher.getOrCreateConnection().setAutoCommit(true); CallableStatement cs = methodWatcher.prepareCall("CALL SYSIBM.METADATA()"); ResultSet rs = cs.executeQuery(); int count = 0; while (rs.next()) { Assert.assertTrue(rs.getBoolean(1)); count++;// ww w. j a v a2 s .c o m } Assert.assertEquals(1, count); DbUtils.closeQuietly(rs); }
From source file:com.wso2telco.proxy.util.DBUtils.java
private static List<LoginHintFormatDetails> getLoginHintFormatTypeDetails(int paramId, Connection conn) throws AuthenticatorException, SQLException { PreparedStatement ps = null;//from w w w.j av a 2 s . c om ResultSet results = null; String sql = "SELECT * FROM `login_hint_format` WHERE `format_id` IN (SELECT `format_id` FROM " + "`scope_supp_login_hint_format` WHERE `param_id` = ?);"; if (log.isDebugEnabled()) { log.debug("Executing the query : " + sql); } List<LoginHintFormatDetails> loginHintFormatDetails = new ArrayList<LoginHintFormatDetails>(); try { ps = conn.prepareStatement(sql); ps.setInt(1, paramId); results = ps.executeQuery(); while (results.next()) { LoginHintFormatDetails loginHintFormat = new LoginHintFormatDetails(); loginHintFormat.setFormatType( LoginHintFormatDetails.loginHintFormatTypes.valueOf(results.getString("type"))); loginHintFormat.setEncrypted(results.getBoolean("is_encrypted")); loginHintFormat.setDecryptAlgorithm(results.getString("decrypt_algorithm")); loginHintFormatDetails.add(loginHintFormat); } } catch (SQLException e) { //using the same connection to avoid connection pool exhaust exception within the loop. SQL exception to // be handled in the parent function. log.error("Error occurred while getting login format details from the database", e); throw e; } finally { closeAllConnections(ps, null, results); } return loginHintFormatDetails; }
From source file:edu.ku.brc.specify.dbsupport.TaskSemaphoreMgr.java
/** * Checks IsLocked and UsageCount for the specified semaphore and returns * true if it is locked or the UsageCount is non-null and non-zero. * //www . j ava 2 s. co m * @param title * @param name * @param scope * @return true if UsageCount is > 0. */ public static boolean isLockedOrInUse(final String title, final String name, final SCOPE scope) { Discipline discipline = scope == SCOPE.Discipline ? AppContextMgr.getInstance().getClassObject(Discipline.class) : null; Collection collection = scope == SCOPE.Collection ? AppContextMgr.getInstance().getClassObject(Collection.class) : null; Connection connection = DBConnection.getInstance().getConnection(); if (connection != null) { Statement stmt = null; ResultSet rs = null; try { String sql = buildSQL(name, scope, discipline, collection, "IsLocked, UsageCount"); //log.debug(sql); stmt = connection.createStatement(); rs = stmt.executeQuery(sql); if (rs != null && rs.next()) { Integer count = rs.getInt(2); return rs.getBoolean(1) || (count == null ? false : count > 0); } return false; } catch (com.mysql.jdbc.exceptions.jdbc4.CommunicationsException ex) { UIRegistry.showLocalizedMsg("TIMEOUT_ERR"); } catch (com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException ex) { UIRegistry.showLocalizedMsg("TIMEOUT_ERR"); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(TaskSemaphoreMgr.class, ex); log.error(ex); } finally { try { if (rs != null) { rs.close(); } if (stmt != null) { stmt.close(); } // if (connection != null) // { // connection.close(); // } } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(TaskSemaphoreMgr.class, ex); log.error(ex); } } } return false; }
From source file:com.googlecode.flyway.core.dbsupport.hsql.HsqlDbSupport.java
public String getCurrentSchema() throws SQLException { ResultSet resultSet = null; String schema = null;/*from w w w . j a v a2 s. c o m*/ try { resultSet = jdbcTemplate.getMetaData().getSchemas(); while (resultSet.next()) { if (resultSet.getBoolean("IS_DEFAULT")) { schema = resultSet.getString("TABLE_SCHEM"); break; } } } finally { JdbcUtils.closeResultSet(resultSet); } return schema; }
From source file:mylife.respository.userDAO.java
/** * * @param start//from ww w . j av a2s .c om * @param total * @return */ public List<user> getuserByPage(int start, int total) { String sql = "SELECT * FROM users LIMIT " + (start - 1) + "," + total; return template.query(sql, new RowMapper<user>() { public user mapRow(ResultSet rs, int row) throws SQLException { user u = new user(); u.setUsername(rs.getString(1)); u.setPassword(rs.getString(2)); u.setEnabled(rs.getBoolean(3)); return u; } }); }
From source file:com.healthcit.analytics.dao.rowmapper.ReportTemplateRowMapper.java
@Override public ReportTemplate mapRow(ResultSet resultSet, int rowNum) throws SQLException { ReportTemplate template = new ReportTemplate(resultSet.getLong(ID_COLUMN), resultSet.getString(TITLE_COLUMN), resultSet.getString(REPORT_COLUMN), resultSet.getTimestamp(TIMESTAMP_COLUMN), resultSet.getLong(OWNER_ID_COLUMN), resultSet.getBoolean(SHARED_COLUMN)); try {// w w w . j av a 2 s . co m resultSet.findColumn(USERNAME_COLUMN); template.setOwnerName(resultSet.getString(USERNAME_COLUMN)); } catch (SQLException ex) { } return template; }
From source file:com.leapfrog.sms.dao.impl.CourseDAOImpl.java
private Course mapData(ResultSet rs) throws SQLException { Course course = new Course(); course.setId(rs.getInt("id")); course.setName(rs.getString("name")); course.setDescription(rs.getString("description")); course.setPrice(rs.getDouble("price")); course.setStatus(rs.getBoolean("status")); return course; }
From source file:mylife.respository.userDAO.java
/** * * @return//from w w w.ja v a 2 s .co m */ public List<user> getuserList() { return template.query("SELECT * FROM users", new RowMapper<user>() { public user mapRow(ResultSet rs, int row) throws SQLException { user u = new user(); u.setUsername(rs.getString("username")); u.setPassword(rs.getString(" Password")); u.setEnabled(rs.getBoolean("enabled")); return u; } }); }
From source file:com.wso2telco.proxy.util.DBUtils.java
/** * Get MSISDN properties by operator Id. * * @param operatorId operator Id./* w ww. ja v a 2 s . c o m*/ * @param operatorName operator Name. * @return MSISDN properties of given operator. * @throws SQLException on errors * @throws NamingException on errors */ public static List<MSISDNHeader> getMSISDNPropertiesByOperatorId(int operatorId, String operatorName) throws SQLException, NamingException { Connection connection = null; PreparedStatement preparedStatement = null; ResultSet resultSet = null; List<MSISDNHeader> msisdnHeaderList = new ArrayList<MSISDNHeader>(); String queryToGetOperatorProperty = "SELECT msisdnHeaderName, isHeaderEncrypted, encryptionImplementation, " + "msisdnEncryptionKey, priority FROM operators_msisdn_headers_properties WHERE operatorId = ? ORDER BY" + " priority ASC"; try { connection = getConnectDBConnection(); preparedStatement = connection.prepareStatement(queryToGetOperatorProperty); preparedStatement.setInt(1, operatorId); resultSet = preparedStatement.executeQuery(); while (resultSet.next()) { MSISDNHeader msisdnHeader = new MSISDNHeader(); msisdnHeader.setMsisdnHeaderName(resultSet.getString(AuthProxyConstants.MSISDN_HEADER_NAME)); msisdnHeader.setHeaderEncrypted(resultSet.getBoolean(AuthProxyConstants.IS_HEADER_ENCRYPTED)); msisdnHeader.setHeaderEncryptionMethod( resultSet.getString(AuthProxyConstants.ENCRYPTION_IMPLEMENTATION)); msisdnHeader.setHeaderEncryptionKey(resultSet.getString(AuthProxyConstants.MSISDN_ENCRYPTION_KEY)); msisdnHeader.setPriority(resultSet.getInt(AuthProxyConstants.PRIORITY)); msisdnHeaderList.add(msisdnHeader); } } catch (SQLException e) { throw new SQLException( "Error occurred while retrieving operator MSISDN properties of operator : " + operatorName, e); } catch (NamingException e) { throw new ConfigurationException("DataSource could not be found in mobile-connect.xml"); } finally { closeAllConnections(preparedStatement, connection, resultSet); } return msisdnHeaderList; }