/* -- ' Copyright by Erica Andrews aka CyLiKoN JeZuZ aka Li'L CJ, ' January 2000. No one is permitted to implement this JavaBean ' or any portion of it on their site without the express written consent ' of the author (cylikon@hotmail.com - ./IcedPinky/). ' All rights reserved. ' This Bean was hand-coded in Java by Erica Andrews on Jan. 11, 2000 ' The bean works as a stored procedure for grabbing related sites in ' my database. The Sites() method then returns ' the RAW, unformatted ResultSet of the query, which can then be formatted ' into links, tables, forms, etc by the same JSP page. The Bean uses the ' gweMySQLJDBC 0.9.2 driver and MySQL 3.22.9 for database connectivity. -- */ package yahoo; import java.io.*; import java.beans.*; import java.util.*; import java.sql.*; import gwe.sql.*; public class YahooBean3 { /* ------Creating a variable to used in the WHERE clause of the SELECT statement. The variable will be defined later in the stored procedures------- */ int x; /* ------Creating a generic JDBC connection method Sites() with the "x" variable to be used by all the miniature "stored procedures" later------- */ public ResultSet Sites() throws SQLException, ClassNotFoundException { Class.forName ("gwe.sql.gweMysqlDriver"); Connection conn = DriverManager.getConnection ("jdbc:mysql://:3306/siteindex2","MySecret","MySecret"); Statement stmt = conn.createStatement (); ResultSet rset = stmt.executeQuery ("SELECT id,itsgroup,url,title,thedate FROM thesites WHERE itsgroup='"+(x)+"'"); return (rset); } // --- ending generic connection method Sites() /* Creating miniature "stored procedures" for accessing sites that are related by: instantiating a new instance of the YahooBean3 bean ("rl") for each method, defining the value of the variable "x" for the generic procedure above "Sites()" as rl.x, then returning the raw ResultSet of the Sites() method above. The raw ResultSet is completely un-formatted and will be formatted later in the JSP page....a good way to keep the actual data retrieved (through the bean) seperate from the presentation (in the JSP page). From this point on, things get very repetitive. The methods below create a collection of new, but very similar YahooBean3 objects. The only property that differs is the value of rl.x, which allows the "x" value of the Sites() method to be controlled remotely. Re-using objects is repetitive, by much easier coding. */ // -- Retrieving Resume sites on my local server, "WHERE itsgroup=51" ---- */ public ResultSet getResumeLocal() throws SQLException, ClassNotFoundException { YahooBean3 rl = new YahooBean3(); rl.x = 51; return (rl.Sites()); } // --- ending stored procdure method // -- Retrieving Tech. Playground sites on my local server, "WHERE itsgroup=52" ---- */ public ResultSet getTechLocal() throws SQLException, ClassNotFoundException { YahooBean3 rl = new YahooBean3(); rl.x = 52; return (rl.Sites()); } // --- ending stored procdure method // -- Retrieving my Home pages on the AOL server, "WHERE itsgroup=1" ---- */ public ResultSet getHome() throws SQLException, ClassNotFoundException { YahooBean3 rl = new YahooBean3(); rl.x = 1; return (rl.Sites()); } // --- ending stored procdure method // -- Retrieving my NYC pages on the AOL server, "WHERE itsgroup=2" ---- */ public ResultSet getNyc() throws SQLException, ClassNotFoundException { YahooBean3 rl = new YahooBean3(); rl.x = 2; return (rl.Sites()); } // --- ending stored procdure method // -- Retrieving my Lesbian-Gay sites on the AOL server, "WHERE itsgroup=5" ---- */ public ResultSet getLgbt() throws SQLException, ClassNotFoundException { YahooBean3 rl = new YahooBean3(); rl.x = 5; return (rl.Sites()); } // --- ending stored procdure method // -- Retrieving my Hiphop pages on the AOL server, "WHERE itsgroup=3" ---- */ public ResultSet getHiphop() throws SQLException, ClassNotFoundException { YahooBean3 rl = new YahooBean3(); rl.x = 3; return (rl.Sites()); } // --- ending stored procdure method // -- Retrieving my Reggae pages on the AOL server, "WHERE itsgroup=4" ---- */ public ResultSet getReggae() throws SQLException, ClassNotFoundException { YahooBean3 rl = new YahooBean3(); rl.x = 4; return (rl.Sites()); } // --- ending stored procdure method // -- Retrieving my Resume pages on the AOL server, "WHERE itsgroup=6" ---- */ public ResultSet getResume() throws SQLException, ClassNotFoundException { YahooBean3 rl = new YahooBean3(); rl.x = 6; return (rl.Sites()); } // --- ending stored procdure method // -- Retrieving the About Me pages on the AOL server, "WHERE itsgroup=7" ---- */ public ResultSet getAboutMe() throws SQLException, ClassNotFoundException { YahooBean3 rl = new YahooBean3(); rl.x = 7; return (rl.Sites()); } // --- ending stored procdure method // -- Retrieving my Search engine pages on the AOL server, "WHERE itsgroup=8" ---- */ public ResultSet getSearch() throws SQLException, ClassNotFoundException { YahooBean3 rl = new YahooBean3(); rl.x = 8; return (rl.Sites()); } // --- ending stored procdure method // -- Retrieving my Ghetto Haunted House pages on the AOL server, "WHERE itsgroup=9" ---- */ public ResultSet getGhettoHaunted() throws SQLException, ClassNotFoundException { YahooBean3 rl = new YahooBean3(); rl.x = 9; return (rl.Sites()); } // --- ending stored procdure method // -- Retrieving my Computers/IT pages on the AOL server, "WHERE itsgroup=10" ---- */ public ResultSet getComputers() throws SQLException, ClassNotFoundException { YahooBean3 rl = new YahooBean3(); rl.x = 10; return (rl.Sites()); } // --- ending stored procdure method } // - End of Class YahooBean