Here you can find the source of getRange(Connection C, String table, String column)
public static double[] getRange(Connection C, String table, String column)
//package com.java2s; //License from project: Open Source License import java.sql.*; public class Main { public static double[] getRange(Connection C, String table, String column) { String query = ""; Statement S;/*from www. j a v a 2 s. c om*/ ResultSet R; double[] range = new double[2]; try { query = "SELECT MIN(" + column + "), MAX(" + column + ") FROM " + table + ";"; S = C.createStatement(); R = S.executeQuery(query); if (R.next()) { range[0] = R.getDouble(1); range[1] = R.getDouble(2); } R.close(); S.close(); } // end try catch (SQLException E) { System.out.println("SQLException: " + E.getMessage()); System.out.println("SQLState: " + E.getSQLState()); System.out.println("VendorError: " + E.getErrorCode()); } // end catch return range; } public static double[] getRange(Connection C, String table, String column, String selection) { String query = ""; Statement S; ResultSet R; double[] range = new double[2]; try { query = "SELECT MIN(" + column + "), MAX(" + column + ") FROM " + table + " WHERE (" + selection + ");"; S = C.createStatement(); R = S.executeQuery(query); if (R.next()) { range[0] = R.getDouble(1); range[1] = R.getDouble(2); } R.close(); S.close(); } // end try catch (SQLException E) { System.out.println("SQLException: " + E.getMessage()); System.out.println("SQLState: " + E.getSQLState()); System.out.println("VendorError: " + E.getErrorCode()); } // end catch return range; } }