commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kulpanowski, David" <>
Subject [math] JDBC output to generate statistical results.
Date Tue, 26 Aug 2014 13:03:13 GMT
Using jdbc I am querying my database of ambulance response times. My goal is to take the output
and process it into statistics using Jakarta Commons Math library. So far I am successful
in querying my database and outputting the response times to the console. My next step is
to process this output statistically, such as mean, medians, mode, etc. This is where I am
stuck. What I can't figure out is how to get my database output into a format for Commons
Math to generate a statistical analysis. In other words, I have 100,000 ambulance responses,
now I want to do more advanced statistical analysis with this data.
Shown below is my code.

package javaDatabase;

import java.sql.*;
import org.apache.commons.math3.stat.StatUtils;

public class javaConnect4
       public static void main(String[] args)
             Connection conn = null;
             Statement stmt = null;
                    conn = DriverManager
                    stmt = conn.createStatement();
                    String strSelect = "SELECT M_SecondsAtStatus FROM MManpower WHERE M_tTime
> 'august 25, 2014' AND M_Code = 'USAR'";

                    ResultSet rset = stmt.executeQuery(strSelect);

                    while (
                           int values = rset.getInt("M_SecondsAtStatus");

                    // I am hoping to derive useful statistics from my database, such as
                    // the following.this uses Jakarta Commons Math
                    System.out.println("min: " + StatUtils.min(values));
                    System.out.println("max: " + StatUtils.max(values));
                    System.out.println("mean: " + StatUtils.mean(values));
                    System.out.println("product: " + StatUtils.product(values));
                    System.out.println("sum: " + StatUtils.sum(values));
                    System.out.println("variance: " + StatUtils.variance(values));

             } catch (SQLException ex)
             } finally
                           if (stmt != null)
                           if (conn != null)
                    } catch (SQLException ex)

An error message pops up in Eclipse and the variable "values" is red underlined; "values cannot
be resolved to a variable".
I am not sure how to get this to work.
I don't understand how to output my ambulance response times from the database into something
Apache Commons math will understand.
How can I get Apache Commons math to take the output from my database and generate a statistical

1.) I have cross-posted this question on but have not resolved the issue.
2.) I have verified that Apache Commons Math is registered in my project by hand coding a
small array and using Commons Math to generate statistics. So Apache Math works and my database
output goes to the console window, so it works also. But how do you get them to work together?
3.) I am a geographer, not a computer programmer. Believe me, you cannot make it simple enough.
Please be explicit in your answers.

David Kulpanowski
Database Analyst
Lee County EMS
PO Box 398
Fort Myers, FL 33902-0398
Longitude: -81.861486
Latitude: 26.528843

Please note: Florida has a very broad public records law. Most written communications to or
from County Employees and officials regarding County business are public records available
to the public and media upon request. Your email communication may be subject to public disclosure.

Under Florida law, email addresses are public records. If you do not want your email address
released in response to a public records request, do not send electronic mail to this entity.
Instead, contact this office by phone or in writing.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message