/** * 获得公司的分部 * * @param con * @param company_code * @return * @throws SQLException */ private static java.util.List<JUnit> getChildBranch(Connection con, String company_code) throws SQLException { java.util.List<JUnit> lsBranch = new java.util.ArrayList<JUnit>(); java.sql.PreparedStatement pstmt = null; ResultSet rs = null; String sql = null; sql = "select unit_id from t_unit " + " where (parent_code =? or parent_code =?) and is_branch = 1 " + " order by unit_index "; pstmt = con.prepareStatement(sql); pstmt.setString(1, company_code); pstmt.setString(2, company_code + ".LX"); rs = pstmt.executeQuery(); while (rs.next()) { JUnit uObj = JUnit.getUnit(rs.getString("unit_id")); lsBranch.add(uObj); } /* if(lsBranch.size() == 0) { lsBranch.add(JUnit.getUnitByCode(company_code)); }*/ rs.close(); pstmt.close(); return lsBranch; }
public ResultSet getForMetricId( String metricId, java.sql.Timestamp startTime, java.sql.Timestamp endTime) { String query = SELECT + "from data_point this\n where\n this.\"metric_id\" = ?\n and this.\"timestamp\" >= ?\n and this.\"timestamp\" <= ?\n order by this.\"timestamp\""; java.sql.PreparedStatement genorm_statement = null; try { genorm_statement = GenOrmDataSource.prepareStatement(query); genorm_statement.setString(1, metricId); genorm_statement.setTimestamp(2, startTime); genorm_statement.setTimestamp(3, endTime); s_logger.debug(genorm_statement.toString()); ResultSet rs = new SQLResultSet(genorm_statement.executeQuery(), query, genorm_statement); return (rs); } catch (java.sql.SQLException sqle) { try { if (genorm_statement != null) genorm_statement.close(); } catch (java.sql.SQLException sqle2) { } if (s_logger.isDebug()) sqle.printStackTrace(); throw new GenOrmException(sqle); } }
public ResultSet getByMetric(String metricId) { String query = SELECT + "FROM data_point this WHERE this.\"metric_id\" = ?"; java.sql.PreparedStatement genorm_statement = null; try { genorm_statement = GenOrmDataSource.prepareStatement(query); genorm_statement.setString(1, metricId); s_logger.debug(genorm_statement.toString()); ResultSet rs = new SQLResultSet(genorm_statement.executeQuery(), query, genorm_statement); return (rs); } catch (java.sql.SQLException sqle) { try { if (genorm_statement != null) genorm_statement.close(); } catch (java.sql.SQLException sqle2) { } if (s_logger.isDebug()) sqle.printStackTrace(); throw new GenOrmException(sqle); } }