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:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskPgSql.CFAsteriskPgSqlSecDeviceTable.java
public void deleteSecDeviceByIdIdx(CFSecurityAuthorization Authorization, UUID argSecUserId, String argDevName) {//from www .j a va 2 s .c o m final String S_ProcName = "deleteSecDeviceByIdIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerDbSchemaName() + ".sp_delete_secdev_by_ididx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByIdIdx == null) { stmtDeleteByIdIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByIdIdx.setString(argIdx++, argSecUserId.toString()); stmtDeleteByIdIdx.setString(argIdx++, argDevName); resultSet = stmtDeleteByIdIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlAuditActionTable.java
public void deleteAuditAction(CFAccAuthorization Authorization, CFAccAuditActionBuff Buff) { final String S_ProcName = "deleteAuditAction"; ResultSet resultSet = null; try {//w w w.j av a2 s. com Connection cnx = schema.getCnx(); short AuditActionId = Buff.getRequiredAuditActionId(); String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_auditaction( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByPKey == null) { stmtDeleteByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByPKey.setShort(argIdx++, AuditActionId); stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision()); ; resultSet = stmtDeleteByPKey.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstPgSql.CFAstPgSqlAuditActionTable.java
public void deleteAuditAction(CFAstAuthorization Authorization, CFAstAuditActionBuff Buff) { final String S_ProcName = "deleteAuditAction"; ResultSet resultSet = null; try {// www .j a v a2s.c om Connection cnx = schema.getCnx(); short AuditActionId = Buff.getRequiredAuditActionId(); String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_auditaction( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByPKey == null) { stmtDeleteByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByPKey.setShort(argIdx++, AuditActionId); stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision()); ; resultSet = stmtDeleteByPKey.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstPgSql.CFAstPgSqlAuditActionTable.java
public void deleteAuditAction(CFAstAuthorization Authorization, CFAstAuditActionBuff Buff) { final String S_ProcName = "deleteAuditAction"; ResultSet resultSet = null; try {//from ww w. j a v a 2 s . c o m Connection cnx = schema.getCnx(); short AuditActionId = Buff.getRequiredAuditActionId(); String sql = "SELECT " + schema.getLowerDbSchemaName() + ".sp_delete_auditaction( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByPKey == null) { stmtDeleteByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByPKey.setShort(argIdx++, AuditActionId); stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision()); ; resultSet = stmtDeleteByPKey.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlISOCountryTable.java
public void deleteISOCountryByIdIdx(CFAccAuthorization Authorization, short argId) { final String S_ProcName = "deleteISOCountryByIdIdx"; ResultSet resultSet = null; try {//from w ww .ja v a 2s. c o m Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_iso_cntry_by_ididx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByIdIdx == null) { stmtDeleteByIdIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByIdIdx.setShort(argIdx++, argId); resultSet = stmtDeleteByIdIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstPgSql.CFAstPgSqlISOCountryTable.java
public void deleteISOCountryByIdIdx(CFAstAuthorization Authorization, short argId) { final String S_ProcName = "deleteISOCountryByIdIdx"; ResultSet resultSet = null; try {// ww w.j ava 2 s . c om Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_iso_cntry_by_ididx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByIdIdx == null) { stmtDeleteByIdIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByIdIdx.setShort(argIdx++, argId); resultSet = stmtDeleteByIdIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstPgSql.CFAstPgSqlISOCountryTable.java
public void deleteISOCountryByIdIdx(CFAstAuthorization Authorization, short argId) { final String S_ProcName = "deleteISOCountryByIdIdx"; ResultSet resultSet = null; try {/*from w ww . j a va 2s . com*/ Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerDbSchemaName() + ".sp_delete_iso_cntry_by_ididx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByIdIdx == null) { stmtDeleteByIdIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByIdIdx.setShort(argIdx++, argId); resultSet = stmtDeleteByIdIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstPgSql.CFAstPgSqlSecDeviceTable.java
public void deleteSecDeviceByIdIdx(CFAstAuthorization Authorization, UUID argSecUserId, String argDevName) { final String S_ProcName = "deleteSecDeviceByIdIdx"; ResultSet resultSet = null; try {// w w w.jav a2s .co m Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerDbSchemaName() + ".sp_delete_secdev_by_ididx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByIdIdx == null) { stmtDeleteByIdIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByIdIdx.setString(argIdx++, argSecUserId.toString()); stmtDeleteByIdIdx.setString(argIdx++, argDevName); resultSet = stmtDeleteByIdIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:com.enonic.vertical.engine.handlers.SectionHandler.java
public void appendSectionNames(int contentKey, Element contentElem) { StringBuffer sql = new StringBuffer(); sql.append("SELECT ").append("sec.").append(db.tMenuItem.mei_lKey).append(", ").append("sec.") .append(db.tMenuItem.mei_men_lKey).append(", ").append("sec.").append(db.tMenuItem.mei_lKey) .append(", ").append("sec.").append(db.tMenuItem.mei_sName).append(", ").append("sec.") .append(db.tMenuItem.mei_lParent).append(", ").append(db.tSectionContent2.sco_bApproved) .append(", ").append(db.tContentHome.cho_mei_lKey).append(", ").append("secparent.") .append(db.tMenuItem.mei_lKey); sql.append(" FROM ").append(db.tMenuItem).append(" sec"); sql.append(" JOIN ").append(db.tSectionContent2).append(" ON ").append("sec.").append(db.tMenuItem.mei_lKey) .append(" = ").append(db.tSectionContent2.sco_mei_lKey); sql.append(" LEFT JOIN ").append(db.tContentHome).append(" ON ").append(db.tContentHome.cho_con_lKey) .append(" = ").append(db.tSectionContent2.sco_con_lKey).append(" AND ") .append(db.tContentHome.cho_men_lKey).append(" = ").append(db.tMenuItem.mei_men_lKey); sql.append(" LEFT JOIN ").append(db.tMenuItem).append(" secparent").append(" ON ").append("secparent.") .append(db.tMenuItem.mei_lKey).append(" = sec.").append(db.tMenuItem.mei_lParent); XDG.appendWhereSQL(sql, db.tSectionContent2.sco_con_lKey, XDG.OPERATOR_EQUAL); sql.append("?"); Connection con = null;//from w w w .ja v a 2 s.co m PreparedStatement preparedStmt = null; ResultSet resultSet = null; Document doc = contentElem.getOwnerDocument(); Element root = XMLTool.createElement(doc, contentElem, "sectionnames"); try { con = getConnection(); preparedStmt = con.prepareStatement(sql.toString()); preparedStmt.setInt(1, contentKey); resultSet = preparedStmt.executeQuery(); while (resultSet.next()) { int sectionKey = resultSet.getInt(1); int menuKey = resultSet.getInt(2); int menuItemKey = resultSet.getInt(3); String name = resultSet.getString(4); // int parentKey = resultSet.getInt(5); boolean approved = resultSet.getBoolean(6); Integer homeMenuItemKey = resultSet.getInt(7); if (resultSet.wasNull()) { homeMenuItemKey = null; } Integer parentSectionKey = resultSet.getInt(8); if (resultSet.wasNull()) { parentSectionKey = null; } Element sectionName = XMLTool.createElement(doc, root, "sectionname", name); sectionName.setAttribute("key", Integer.toString(sectionKey)); sectionName.setAttribute("menukey", Integer.toString(menuKey)); sectionName.setAttribute("menuitemkey", Integer.toString(menuItemKey)); boolean home = homeMenuItemKey != null && homeMenuItemKey == menuItemKey; if (home) { sectionName.setAttribute("home", "true"); } if (parentSectionKey != null) { sectionName.setAttribute("supersectionkey", Integer.toString(parentSectionKey)); } sectionName.setAttribute("approved", String.valueOf(approved)); } } catch (SQLException sqle) { String message = "Failed to append section names to content: %t"; VerticalEngineLogger.error(this.getClass(), 1, message, sqle); } finally { close(resultSet); close(preparedStmt); close(con); } }
From source file:fi.helsinki.cs.iot.kahvihub.database.sqliteJdbc.IotHubDatabaseSqliteJDBCImpl.java
private List<Feature> getFeaturesForEnabler(Enabler enabler) { List<Feature> features = new ArrayList<Feature>(); try {/*from w w w . j a v a 2 s . c om*/ checkOpenness(); String sql = "select * from " + IotHubDataHandler.TABLE_FEATURE + " where " + IotHubDataHandler.KEY_FEATURE_ENABLER_ID + "=?"; PreparedStatement ps = connection.prepareStatement(sql); ps.setLong(1, enabler.getId()); ResultSet rs = ps.executeQuery(); while (rs.next()) { long featureId = rs.getLong(IotHubDataHandler.KEY_FEATURE_ID); String name = rs.getString(IotHubDataHandler.KEY_FEATURE_NAME); String type = rs.getString(IotHubDataHandler.KEY_FEATURE_TYPE); boolean isFeed = rs.getBoolean(IotHubDataHandler.KEY_FEATURE_IS_FEED); Feature feature = new Feature(featureId, enabler, name, type); feature.setAtomicFeed(isFeed); features.add(feature); Log.d(TAG, "Got one feature from the db"); } rs.close(); ps.close(); } catch (SQLException | IotHubDatabaseException e) { e.printStackTrace(); return null; } return features; }