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.micromux.cassandra.jdbc.JdbcRegressionTest.java
/** * Test an update statement; confirm that the results can be read back. */// w w w . j av a2 s .co m @Test public void testExecuteUpdate() throws Exception { String insert = "INSERT INTO regressiontest (keyname,bValue,iValue) VALUES( 'key0',true, 2000);"; Statement statement = con.createStatement(); statement.executeUpdate(insert); statement.close(); statement = con.createStatement(); ResultSet result = statement.executeQuery("SELECT bValue,iValue FROM regressiontest WHERE keyname='key0';"); result.next(); boolean b = result.getBoolean(1); assertTrue(b); int i = result.getInt(2); assertEquals(2000, i); }
From source file:com.apatar.buzzsaw.BuzzsawNode.java
@Override protected void TransformTDBtoRDB(int mode) { try {/* ww w.j a v a 2 s .com*/ DataBaseTools.completeTransfer(); TableInfo ti = getTiForConnection(IN_CONN_POINT_NAME); ResultSet rs = DataBaseTools.getRSWithAllFields(ti.getTableName(), ApplicationData.tempDataBase.getJdbcParams(), ApplicationData.getTempDataBaseInfo()); WebdavResource resource = null; while (rs.next()) { boolean isFolder = rs.getBoolean("isFolder"); resource = getBindingBuzzsaw(); // pathRes - path to resource String pathRes = convertHttpToString(resource.getHttpURL()); // path - inner path from db String path = rs.getString("Path"); if (path.length() > 0) { if (separator.equals(path.substring(0, 1)) || "\\".equals(path.substring(0, 1))) { pathRes += path; } else { pathRes = pathRes + separator + path; } } if (isFolder) { resource.mkcolMethod(pathRes); } else { InputStream in = rs.getBinaryStream("Content"); if (null != in) { resource.putMethod(pathRes, in); in.close(); } else { // if Content field is null, but String_Content field is // not null String strContent = rs.getString("String_Content"); if (null != strContent && !"".equals(strContent)) { byte[] bytes = strContent.getBytes(); resource.putMethod(pathRes, bytes); } else { resource.putMethod(pathRes, ""); } } } if (!ApplicationData.ProcessingProgress.Step()) { return; } ApplicationData.ProcessingProgress.Log("Uploading resource: " + pathRes); } } catch (Exception e1) { ApplicationData.ProcessingProgress.Log(e1); e1.printStackTrace(); } finally { DataBaseTools.completeTransfer(); } }
From source file:com.atolcd.alfresco.repo.patch.SchemaUpgradeScriptPatch.java
/** * @return Returns the number of applied patches *///from ww w . java 2 s . c om private boolean didPatchSucceed(Connection connection, String patchId) throws Exception { String patchTableName = getAppliedPatchTableName(connection); if (patchTableName == null) { // Table doesn't exist, yet return false; } Statement stmt = connection.createStatement(); try { ResultSet rs = stmt .executeQuery("select succeeded from " + patchTableName + " where id = '" + patchId + "'"); if (!rs.next()) { return false; } boolean succeeded = rs.getBoolean(1); return succeeded; } finally { try { stmt.close(); } catch (Throwable e) { } } }
From source file:edu.northwestern.bioinformatics.studycalendar.domain.tools.hibernate.ScheduledActivityStateType.java
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { // we don't know the owner yet, but that's okay because the MODE_TYPE doesn't use it. ScheduledActivityMode mode = (ScheduledActivityMode) MODE_TYPE.nullSafeGet(rs, names[MODE_INDEX], session, null);/* www.j av a 2s. c o m*/ ScheduledActivityState loaded = createStateObject(mode); if (loaded == null) return null; loaded.setReason(rs.getString(names[REASON_INDEX])); loaded.setDate(rs.getTimestamp(names[DATE_INDEX])); loaded.setWithTime(rs.getBoolean(names[WITH_TIME_INDEX])); return loaded; }
From source file:com.sfs.whichdoctor.dao.IsbMessageDAOImpl.java
/** * Load isb message bean./*w ww . ja v a 2 s . c o m*/ * * @param rs the rs * * @return the isb message bean * * @throws SQLException the SQL exception */ private IsbMessageBean loadIsbMessageBean(final ResultSet rs) throws SQLException { final IsbMessageBean message = new IsbMessageBean(); message.setId(rs.getInt("Id")); message.setSource(rs.getString("Source")); message.setTarget(rs.getString("IsbTarget")); message.setAction(rs.getString("Action")); message.setIdentifier(rs.getString("Identifier")); message.setIsInbound(rs.getBoolean("IsInbound")); message.setProcessed(rs.getBoolean("Processed")); try { message.setCreatedDate(rs.getTimestamp("Created")); } catch (SQLException e) { dataLogger.debug("Error reading Created date: " + e.getMessage()); } // Load the ISB payload try { message.setIsbPayload(this.isbPayloadDAO.loadSiblingOf(message.getId())); } catch (WhichDoctorDaoException wde) { dataLogger.debug("Error loading ISB payload: " + wde.getMessage()); } return message; }
From source file:com.spvp.dal.MySqlDatabase.java
@Override public Grad dajGradPoImenu(String imeGrada) throws SQLException { int id;/* w ww . j ava 2 s .c o m*/ String ime; Double longitude; Double latitude; Boolean veciCentar; try (Connection conn = getConnection()) { PreparedStatement ps = conn.prepareStatement("SELECT id, ime, longitude, latitude, veci_centar " + "FROM gradovi " + "WHERE LOWER(ime) LIKE LOWER(?) "); ps.setString(1, imeGrada); ResultSet rs = ps.executeQuery(); rs.next(); id = rs.getInt("id"); ime = rs.getString("ime"); longitude = rs.getDouble("longitude"); latitude = rs.getDouble("latitude"); veciCentar = rs.getBoolean("veci_centar"); } Grad g = new Grad(ime, longitude, latitude, veciCentar); g.setIdGrada(id); return g; }
From source file:dbProcs.Getter.java
/** * Returns true if a module has a hard coded key, false if server encrypts it * @param ApplicationRoot The current running context of the application * @param moduleId The id of the module * @return Returns true if a module has a hard coded key, false if server encrypts it *//*from w w w . j av a 2 s. com*/ public static boolean getModuleKeyType(String ApplicationRoot, String moduleId) { log.debug("*** Getter.getModuleKeyType ***"); boolean theKeyType = true; Connection conn = Database.getCoreConnection(ApplicationRoot); try { PreparedStatement prepstmt = conn .prepareStatement("SELECT hardcodedKey FROM modules WHERE moduleId = ?"); prepstmt.setString(1, moduleId); ResultSet moduleFind = prepstmt.executeQuery(); moduleFind.next(); theKeyType = moduleFind.getBoolean(1); if (theKeyType) log.debug("Module has hard coded Key"); else log.debug("Module has user specific Key"); } catch (Exception e) { log.error("Module did not exist: " + e.toString()); theKeyType = true; } Database.closeConnection(conn); log.debug("*** END getModuleKeyType ***"); return theKeyType; }
From source file:com.leapfrog.inventorymanagementsystem.dao.impl.ProductDAOImpl.java
@Override public Product getById(int id) throws SQLException, ClassNotFoundException { String sql = "SELECT * FROM tbl_product WHERE product_id =?"; return jdbcTemplate.queryForObject(sql, new Object[] { id }, new RowMapper<Product>() { @Override//from w w w .j a v a 2s . co m public Product mapRow(ResultSet rs, int i) throws SQLException { Product p = new Product(); p.setId(rs.getInt("product_id")); p.setProductName(rs.getString("product_name")); p.setCostPrice(rs.getInt("cost_price")); p.setSellingPrice(rs.getInt("selling_price")); p.setDiscount(rs.getBigDecimal("discount")); p.setQuantity(rs.getInt("quantity")); p.setCategoryName(rs.getString("category_name")); p.setSupplierId(rs.getInt("supplier_id")); p.setAddedDate(rs.getDate("added_date")); p.setModifiedDate(rs.getDate("modified_date")); p.setStatus(rs.getBoolean("status")); return p; } }); }
From source file:com.p000ison.dev.simpleclans2.converter.Converter.java
public void convertPlayers() throws SQLException { ResultSet result = from.query("SELECT * FROM `sc_players`;"); while (result.next()) { JSONObject flags = new JSONObject(); try {//from w w w.j av a2s.c o m JSONParser parser = new JSONParser(); String flagsString = result.getString("flags"); JSONObject object = (JSONObject) parser.parse(flagsString); boolean friendlyFire = result.getBoolean("friendly_fire"); boolean bb = (Boolean) object.get("bb-enabled"); boolean cape = (Boolean) object.get("cape-enabled"); if (friendlyFire) { flags.put("ff", friendlyFire); } if (bb) { flags.put("bb", bb); } if (cape) { flags.put("cape", cape); } } catch (ParseException e) { e.printStackTrace(); continue; } String name = result.getString("name"); insertPlayer(name, result.getBoolean("leader"), result.getBoolean("trusted"), result.getLong("join_date"), result.getLong("last_seen"), getIDByTag(result.getString("tag")), result.getInt("neutral_kills"), result.getInt("rival_kills"), result.getInt("civilian_kills"), result.getInt("deaths"), flags.toJSONString()); ResultSet idResult = to.query("SELECT id FROM `sc2_players` WHERE name = '" + name + "';"); idResult.next(); players.add(new ConvertedClanPlayer(idResult.getLong("id"), name)); } }
From source file:com.leapfrog.inventorymanagementsystem.dao.impl.ProductDAOImpl.java
@Override public List<Product> getALL(boolean inStock) throws SQLException, ClassNotFoundException { String sql = "SELECT * FROM tbl_product WHERE 1=1"; if (inStock) { sql += " AND status=1 "; }/*from www . j av a2 s. c om*/ return jdbcTemplate.query(sql, new RowMapper<Product>() { @Override public Product mapRow(ResultSet rs, int i) throws SQLException { Product p = new Product(); p.setId(rs.getInt("product_id")); p.setProductName(rs.getString("product_name")); p.setCostPrice(rs.getInt("cost_price")); p.setSellingPrice(rs.getInt("selling_price")); p.setDiscount(rs.getBigDecimal("discount")); p.setQuantity(rs.getInt("quantity")); p.setCategoryName(rs.getString("category_name")); p.setSupplierId(rs.getInt("supplier_id")); p.setAddedDate(rs.getDate("added_date")); p.setModifiedDate(rs.getDate("modified_date")); p.setStatus(rs.getBoolean("status")); return p; } }); }