// Layout: // Part I // 1. Are we using a proxy server? // 2. Open the URL and get the data // // Part II // Parse the data // // Part III // Connect to the DB and do the query with the data import java.net.*; import java.sql.*; import java.util.*; import java.io.*; import com.ibm.xml.parsers.DOMParser; import com.bpsinfo.javassl.*; import HTTPClient.*; import org.w3c.dom.*; import ProxyObject; import SiteObject; public class FetchApp extends Object { // globals boolean useProxy=false; static int gArrayLength=10; static ProxyObject proxyInfo=new ProxyObject(); static SiteObject[] siteInfo=new SiteObject[gArrayLength]; // *********************************** // // main // // Notes: the starting point for it all // // *********************************** public static void main(String[] args) throws IOException, UnknownHostException { init(); myReadPrefs(); String container=null; int location=0, location2=0; // for now just spit the output to the terminal window int x=0; while ((siteInfo[x].URL!=null) && (xgArrayLength) { System.out.println("Error: More sites than space available. Please increase the size of the gArrayLength variable."); return; } } // else if=siteinfo } // if theMap!=null } // for i: " + host + "\n"); System.out.print(e+"\n"); e.printStackTrace(); return; } Statement stmt = null; try { stmt = con.createStatement(); query="insert into "+table+"(info) values(\""+value+"\")"; rs = stmt.executeQuery(query); // System.out.print("\n
Query: "+query); // echo the query to the command line for debugging // now turn around pull out the contents and display it to the screen query="select * from "+table; rs = stmt.executeQuery(query); rsmd = rs.getMetaData (); // now you would use rsmd to check for the results of a select query int numCols = rsmd.getColumnCount (); while (rs.next()) { for (int i = 1; i <= numCols; i++) { System.out.println(rs.getString(i)); } } // while } // try catch (SQLException e) { con = null; System.out.print("SQL Exception: " + host + "\n"); System.out.print(e+"\n"); return; } finally { try { if (rs!=null) rs.close(); stmt.close(); if (con!=null) con.close(); } catch (SQLException e) { System.out.print("SQL Exception during close: "+e+"\n"); } } } // toDatabase } // end class FetchApp