import java.sql.SQLException; import java.util.*; import java.io.*; import Zql.*; public class testing { public void processQuery(ZQuery zquery) { Solver s = new Solver(); QueryObject ob = new QueryObject(zquery); if(s.isQuerySatisfiable(ob)) // partial or total { //if(s.getRemainder()==null) System.out.println("Remainder Query is null: in class Composition"); //ResultDisplay.display(rs); //postProcessing(zquery,rs); WILL DECIDE LATER WHAT TO STORE } else // unsatisfiable and hence send the original user query to the remote database { postProcessing(ob); //ResultDisplay.display(rs); } } public void postProcessing(QueryObject ob) { /* store the queries and the data in the database */ /* update the local data structures */ Cache.updateCache(ob); System.out.println("cache updated"); } /* * The Main program stats from here. * Read SQL statements from a file, and process them one at a time */ public static void main(String args[]) { Auxiliary.init(); Cache.init(); try { ZqlParser p = null; if(args.length < 1) { System.out.println("Reading SQL from stdin (quit; or exit; to quit)"); p = new ZqlParser(System.in); } else { p = new ZqlParser(new DataInputStream(new FileInputStream(args[0]))); } testing c = new testing(); // Read all SQL statements from input ZStatement st; while((st = p.readStatement()) != null) { //System.out.println(st.toString() + " in class Composition.java "); // Display the statement if(st instanceof ZQuery) // An SQL query { c.processQuery((ZQuery)st); System.out.println("---------------------------------------------------------"); System.out.println(); System.out.println(); } else System.out.println("invalid SQL syntax : in class testing"); // invalid SQL syntax // you will probably never reach here, since ZqlParser takes care of SQL syntax } // end of while loop } catch(Exception e) {e.printStackTrace();} } }