ApplicationVaribles.class
/**************************************************** Connect to NIC table and extracts the varibles Setting them into InlandRevVar ****************************************************/ package com; import java.io.*; import java.sql.*; import java.util.*; import java.lang.*; import com.ConnectionPool2; import com.PrintToFile; public class ApplicationVaribles { double LELweek; double ETweek; double UELweek; ArrayList NIClist; Connection connection; public ApplicationVaribles() { body(); } public void body() { //Gets the connection connection = ConnectionPool2.getConnection(); first(); second(); System.out.println("In ApplicationVaribles main"); third(); forth(); ConnectionPool2.returnConnection(connection); } //retrives from the data base the NIC boundaries. public void first() { try { String query = "SELECT * FROM NICvar"; Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery( query ); openResultSet( resultSet ); statement.close(); } catch(SQLException sqle) { //Error code to be entered here } } public void openResultSet(ResultSet r)throws SQLException { r.next(); //Removes the inland revenue varibles from the result set and parses them //to the static methods class InlandRevVar InlandRevVar.setLELweek(r.getDouble(2)); r.next(); InlandRevVar.setETweek(r.getDouble(2)); r.next(); InlandRevVar.setUELweek(r.getDouble(2)); r.next(); InlandRevVar.setLELmonth(r.getDouble(2)); r.next(); InlandRevVar.setETmonth(r.getDouble(2)); r.next(); System.out.println("In ApplicationVaribles2"); InlandRevVar.setUELmonth(r.getDouble(2)); } public void second() { try { String query2 = "SELECT * FROM NICtables"; Statement statement2 = connection.createStatement(); ResultSet resultSet2 = statement2.executeQuery( query2 ); openResultSet2( resultSet2 ); statement2.close(); } catch(SQLException sqle) { //Error code to be entered here } } public void openResultSet2(ResultSet r)throws SQLException { NIClist = new ArrayList(); int h = 0; // while(h < 2) //Loop throught records in the resultSet placing them in an ArrayList. while(r.next()) { NIClist.add(r.getString(1)); //Converts the double to a Double Object Double d = new Double(r.getDouble(2)); NIClist.add(d); Double dd = new Double(r.getDouble(3)); NIClist.add(dd); h++; } //Passes the ArrayList to static method of InlandRevVar InlandRevVar.setNICList(NIClist); } public void third() { try { String query3 = "SELECT * FROM TaxBoundaries"; Statement statement3 = connection.createStatement(); ResultSet resultSet3 = statement3.executeQuery( query3 ); openResultSet3(resultSet3 ); statement3.close(); } catch(SQLException sqle) { //Error code to be entered here } } public void openResultSet3(ResultSet re)throws SQLException { re.next(); InlandRevVar.setLowerBoundary(re.getDouble(2)); re.next(); InlandRevVar.setUpperBoundary(re.getDouble(2)); } public void forth() { try { String query4 = "SELECT * FROM TaxRates"; Statement statement4 = connection.createStatement(); ResultSet resultSet4 = statement4.executeQuery( query4 ); openResultSet4(resultSet4 ); statement4.close(); } catch(SQLException sqle) { //Error code to be entered here } } public void openResultSet4(ResultSet r)throws SQLException { r.next(); //Removes the inland revenue varibles from the result set and parses them //to the static methods of class InlandRevVar InlandRevVar.setStartingRate(r.getDouble(2)); r.next(); InlandRevVar.setBasicRate(r.getDouble(2)); r.next(); InlandRevVar.setHigherRate(r.getDouble(2)); } }