I'm new to java.This question may have answers but I could not find one. I have to create a method in java in which I have to retrieve values from database and have to consider those column values where "OFF" is not displayed in database.Then the average of those values has to be calculated.Right now I'm looking at database and manually considering only those column which has some double values instead of "OFF". But now this has to be done dynamically. I have total 8 columns in which I have to take only 3 columns as in other columns no value is there only "OFF" is being displayed ,whose average I'm able to calculate.The code for it is
try {
con = getConnection();
String sql = "exec vcs_gauge @gauge_name=?,@first_rec_time=?,@last_rec_time=?";
clstmt = con.prepareCall(sql);
clstmt.setString(1, "vs3_bag");
clstmt.setString(2, "2014-09-01 10:00:00");
clstmt.setString(3, "2014-09-01 11:00:00");
clstmt.execute();
rs = clstmt.getResultSet();
while (rs.next()) {
a4 = rs.getDouble(7);
a5 = rs.getDouble(8);
a6 = rs.getDouble(10);
averageMap3.put(rs.getString(1), (a4 + a5 + a6) / 3.0);
}
//System.out.println("valus is" +averageList);
I want now that instead of specifying the columns which i want to take,a condition is executed which checks if any of the retrieved column has string "OFF" value then it shold not be considered for average calculation. I have to calculate the average in row -wise fashion i.e average of all column of a row will be calculated. Thank in advance