List of usage examples for java.sql ResultSet getLong
long getLong(String columnLabel) throws SQLException;
ResultSet
object as a long
in the Java programming language. From source file:gan.ism.ws.DrmLicense.java
/** * UserID commodity_id ? ,?//from w w w .ja va 2 s . c o m * ?? * {"result":0,"msg":??, order_id":1111, "expired_date":? 2012-12-27 12:59:59?,"playback_count":30 } * {"result":-1,"msg":???} */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String user_id = request.getParameter("user_id"); String commodity_id = request.getParameter("commodity_id"); int status = -1; String msg = "?"; Long order_id = null; mLogger.debug("select t.id as order_id from transaction t, cas_transaction cas_t where t.c_user_id =" + user_id + " and cas_t.commodity_id =" + commodity_id + " and t.id=cas_t.transaction_id and t.payment_state=1 "); Connection conn = MssqlDB.createConnection(); ResultSet rs = MssqlDB.getInstance().executeQuery(conn, str, new Object[] { user_id, commodity_id }); try { if (rs.next()) { order_id = rs.getLong("order_id"); status = 0; msg = ""; } rs.close(); conn.close(); } catch (SQLException e) { e.printStackTrace(); } Map<String, Object> map = new HashMap<String, Object>(); map.put("result", status); map.put("msg", msg); if (status == 0) { map.put("order_id", order_id); map.put("expired_date", ""); //? map.put("playback_count", -1); //? } JSONObject jo = JSONObject.fromObject(map); response.setContentType("text/html; charset=UTF-8"); mLogger.debug("C?" + jo.toString()); response.getWriter().write(jo.toString()); }
From source file:com.mmnaseri.dragonfly.dialect.impl.Mysql5Dialect.java
@Override public Serializable retrieveKey(ResultSet generatedKeys) throws SQLException { return generatedKeys.getLong(1); }
From source file:de.ingrid.importer.udk.strategy.v2.IDCStrategy2_3_1.java
protected void migrateUserGroupAssociations() throws Exception { if (log.isInfoEnabled()) { log.info("Migrate User Group Association..."); }/*from ww w .j av a 2 s. co m*/ String sql = "select distinct id, idc_group_id " + "from idc_user"; Statement st = jdbc.createStatement(); ResultSet rs = jdbc.executeQuery(sql, st); int numMigrated = 0; while (rs.next()) { long userId = rs.getLong("id"); long groupId = rs.getLong("idc_group_id"); sql = "INSERT INTO idc_user_group (id, idc_user_id, idc_group_id) " + "VALUES (" + getNextId() + ", " + userId + ", " + groupId + ")"; jdbc.executeUpdate(sql); numMigrated++; if (log.isDebugEnabled()) { log.debug("Migrated user (id:" + userId + ") with group (id:" + groupId + ")."); } } rs.close(); st.close(); if (log.isDebugEnabled()) { log.debug("Migrated " + numMigrated + " user group associations."); } if (log.isInfoEnabled()) { log.info("Migrate User Group Association... done"); } }
From source file:com.carfinance.module.vehiclemanage.domain.VehicleInfoRowMapper.java
public VehicleInfo mapRow(ResultSet rs, int arg1) throws SQLException { VehicleInfo vehicleInfo = new VehicleInfo(); vehicleInfo.setId(rs.getLong("id")); vehicleInfo.setBrand(rs.getString("brand")); vehicleInfo.setModel(rs.getString("model")); vehicleInfo.setColor(rs.getString("color")); vehicleInfo.setCarframe_no(rs.getString("carframe_no")); vehicleInfo.setEngine_no(rs.getString("engine_no")); vehicleInfo.setBuy_at(rs.getDate("buy_at")); vehicleInfo.setSupplier(rs.getString("supplier")); vehicleInfo.setLicense_plate(rs.getString("license_plate")); vehicleInfo.setCard_at(rs.getDate("card_at")); vehicleInfo.setLimited_at(rs.getDate("limited_at")); vehicleInfo.setGuide_price(rs.getDouble("guide_price")); vehicleInfo.setVehicle_price(rs.getDouble("vehicle_price")); vehicleInfo.setVehicle_tax(rs.getDouble("vehicle_tax")); vehicleInfo.setInsurance_company(rs.getString("insurance_company")); vehicleInfo.setStrong_insurance(rs.getDouble("strong_insurance")); vehicleInfo.setStrong_insurance_expire_at(rs.getDate("strong_insurance_expire_at")); vehicleInfo.setVehicle_vessel_tax(rs.getDouble("vehicle_vessel_tax")); vehicleInfo.setBusiness_insurance(rs.getDouble("business_insurance")); vehicleInfo.setBusiness_insurance_expire_at(rs.getDate("business_insurance_expire_at")); vehicleInfo.setKm(rs.getLong("km")); vehicleInfo.setMaintian_on_km(rs.getLong("maintian_on_km")); vehicleInfo.setGps(rs.getString("gps")); vehicleInfo.setCurrent_city(rs.getLong("current_city")); vehicleInfo.setCurrent_shop(rs.getLong("current_shop")); vehicleInfo.setLease_status(rs.getString("lease_status")); vehicleInfo.setPeccancy_status(rs.getString("peccancy_status")); vehicleInfo.setArchive_no(rs.getString("archive_no")); vehicleInfo.setInventory_no(rs.getString("inventory_no")); vehicleInfo.setRegistry_certificate(rs.getString("registry_certificate")); vehicleInfo.setCertificate_direction(rs.getString("certificate_direction")); vehicleInfo.setLoan_bank(rs.getString("loan_bank")); vehicleInfo.setConsistency_cer(rs.getString("consistency_cer")); vehicleInfo.setCheck_list(rs.getString("check_list")); vehicleInfo.setDuty_paid_proof(rs.getString("duty_paid_proof")); vehicleInfo.setRecord(rs.getString("record")); vehicleInfo.setRemark(rs.getString("remark")); vehicleInfo.setCreate_by(rs.getLong("create_by")); vehicleInfo.setCreate_at(rs.getDate("create_at")); vehicleInfo.setCreate_by(rs.getLong("update_by")); vehicleInfo.setCreate_at(rs.getDate("update_at")); vehicleInfo.setOriginal_org(rs.getLong("original_org")); vehicleInfo.setNext_main_km(rs.getLong("next_main_km")); try {/*from www. j a va 2 s.c o m*/ vehicleInfo.setFinancing_rent_company(rs.getString("financing_rent_company")); } catch (Exception e) { } try { vehicleInfo.setFinancing_rent_price(rs.getDouble("financing_rent_price")); } catch (Exception e) { } try { vehicleInfo.setBail(rs.getDouble("bail")); } catch (Exception e) { } try { vehicleInfo.setMonthly_payment(rs.getDouble("monthly_payment")); } catch (Exception e) { } try { vehicleInfo.setEtc(rs.getString("etc")); } catch (Exception e) { } try { vehicleInfo.setEtc_money(rs.getDouble("etc_money")); } catch (Exception e) { } try { vehicleInfo.setOil_percent(rs.getInt("oil_percent")); } catch (Exception e) { } try { vehicleInfo.setDaily_price(rs.getDouble("daily_price")); } catch (Exception e) { } return vehicleInfo; }
From source file:mvc.dao.TarefaDAO.java
public List<Tarefa> listarTarefas() { List<Tarefa> listaTarefas = new ArrayList<Tarefa>(); String sql = "select * from tarefas order by descricao"; try (PreparedStatement stmt = connection.prepareStatement(sql)) { ResultSet rs = stmt.executeQuery(); while (rs.next()) { Tarefa tarefa = new Tarefa(); tarefa.setId(rs.getLong("id")); tarefa.setDescricao(rs.getString("descricao")); tarefa.setFinalizado(rs.getBoolean("finalizado")); //montando data Calendar data = Calendar.getInstance(); if (rs.getDate("dataFinalizacao") != null) { data.setTime(rs.getDate("dataFinalizacao")); tarefa.setDataFinalizacao(data); }/*w w w . j av a 2 s . c om*/ listaTarefas.add(tarefa); } } catch (SQLException e) { throw new RuntimeException(e); } return listaTarefas; }
From source file:com.senior.g40.service.UserService.java
private long getLatestUserId() throws SQLException { Connection conn = ConnectionBuilder.getConnection(); String sqlCmd = "SELECT MAX(userId) AS latestId FROM `profile`;"; PreparedStatement pstm = conn.prepareStatement(sqlCmd); ResultSet rs = pstm.executeQuery(); if (rs.next()) { long latestId = rs.getLong("latestId"); conn.close();//from w w w . ja v a 2s. c o m return latestId; } else { conn.close(); throw new SQLException("Latest userId is N/A."); } }
From source file:com.haulmont.cuba.core.app.NumberIdWorker.java
protected Object executeScript(String entityName, String sqlScript) { EntityManager em = persistence.getEntityManager(getDataStore(entityName)); StrTokenizer tokenizer = new StrTokenizer(sqlScript, SequenceSupport.SQL_DELIMITER); Object value = null;//www . ja va 2s . c o m Connection connection = em.getConnection(); while (tokenizer.hasNext()) { String sql = tokenizer.nextToken(); try { PreparedStatement statement = connection.prepareStatement(sql); try { if (statement.execute()) { ResultSet rs = statement.getResultSet(); if (rs.next()) value = rs.getLong(1); } } finally { DbUtils.closeQuietly(statement); } } catch (SQLException e) { throw new IllegalStateException("Error executing SQL for getting next number", e); } } return value; }
From source file:com.onclave.testbench.jdbcTemplate.DAOSupport.StudentDAOImplementation.java
@Override public List<StudentPOJO> queryAllStudents() { List<StudentPOJO> students = this.jdbcTemplate.query(QueryStatements.QUERY_ALL_STUDENTS_SQL, new RowMapper<StudentPOJO>() { @Override//from w w w . j a va 2 s .c om public StudentPOJO mapRow(ResultSet resultSet, int rowNum) throws SQLException { StudentPOJO student = new StudentPOJO(); student.setIdStudent(resultSet.getLong("IDStudents")); student.setName(resultSet.getString("studentName")); student.setRollNo(resultSet.getString("studentRollNo")); student.setEmail(resultSet.getString("studentEmail")); student.setActive(resultSet.getBoolean("studentActive")); student.setAge(resultSet.getInt("studentAge")); return student; } }); return students; }
From source file:com.persistent.cloudninja.mapper.UsageRowMapper.java
@Override public Usage mapRow(ResultSet rs, int rowNum) throws SQLException { Usage usage = new Usage(); usage.setTenantId(rs.getString("TenantId")); usage.setYear(rs.getInt("Year")); usage.setMonth(rs.getInt("Month")); usage.setDatabaseSize(rs.getLong("DatabaseSize")); usage.setDatabaseBandwidth_Ingress(rs.getLong("DatabaseBandwidth_Ingress")); usage.setDatabaseBandwidth_Egress(rs.getLong("DatabaseBandwidth_Egress")); usage.setWebAppBandwithUse_CS(rs.getLong("WebAppBandwithUse_CS")); usage.setWebAppBandwithUse_SC(rs.getLong("WebAppBandwithUse_SC")); usage.setWebAppRequests(rs.getLong("WebAppRequests")); usage.setBlobStoreUsage(rs.getLong("BlobStoreUsage")); usage.setTotalRequestPacketSize(rs.getLong("TotalRequestPacketSize")); usage.setTotalResponsePacketSize(rs.getLong("TotalResponsePacketSize")); usage.setTotalStorageTransactions(rs.getLong("TotalStorageTransactions")); return usage; }