// ------------------------------------------------------ // job.jhtml // // This page shows the details for a single job ad. // // Copyright (c) 1998. Stephen M. Bate, // Object Computing, Inc. All rights reserved. // // This software is being provided by the copyright // holder under the following license. By obtaining, using // and/or copying this software, you agree that you have // read, understood, and will comply with the following // terms and conditions: // // Permission to use, copy, modify, and distribute this // software and its documentation for any purpose and // without fee or royalty is hereby granted, provided that // the full text of this NOTICE appears on ALL copies of // the software and documentation or portions thereof, // including modifications, that you make. // // THIS SOFTWARE IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS // MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR // IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, // COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES // OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE // OR THAT THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT // INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS // OR OTHER RIGHTS. COPYRIGHT HOLDERS WILL BEAR NO // LIABILITY FOR ANY USE OF THIS SOFTWARE OR DOCUMENTATION. // // Title to copyright in this software and any associated // documentation will at all times remain with copyright // holder. PHXJUG Job Listing // ------------------------------------------------------ // See index.jhtml for more details about import and extends. java.sql.* org.phxjug.db.DatabaseServlet


[Job Listings] [Maintain Jobs]

// Retrieve the job details we want to display. // Declare connection, statement, and result set variables // which will be used to access the database using JDBC. // These variables are declared outside the try block so // they will be available in the catch block if an error // occurs. Connection con = null; PreparedStatement stmt = null; ResultSet result = null; // This page expects an id to be specified. If it isn't // specified, then flag an error. String id; if ((id = request.getParameter("id")) != null) { // Note: getParameter is now deprecated, but the alternative // is a real pain to use. According to the API, you should // now use getParameters() which returns a string array. // This is very inconvenient if you just need to access a // single value parameter. try { // Get the connection - this accesses the connection pool // defined in the base class. Create the statement using // the connection. The query retrieves all jobs with // the specified id (should only be a single job). con = getConnection(); String query = "select * from job where id = ? and active = 'Y'"; stmt = con.prepareStatement(query); // The the value for the id placeholder and execute // the query. stmt.setString(1, id); result = stmt.executeQuery(); // We will loop over the results, but there should only // be one match since id is a primary key. while(result.next()) { // Get the columns we want to display String abs = result.getString("abstract"); String detail = result.getString("description");

abs

  detail
// // This is the trailing Java code which wraps the row generation. // Notice the while block started before the row generation and // ends after this comment. } // end of while loop } // end of try block surrounding query // // Handle any exceptions that occurred during the row // generation. // catch (Exception e) { getServletContext().log(e, "query failed"); } finally { try { // Close the statement and result set, // if they were created before the exception occurred. if (stmt != null) stmt.close(); if (result != null) result.close(); } // Even the cleanup can cause an exception! catch (Exception e) { getServletContext().log(e, "query cleanup failed"); } // Return the connection to the pool, so the next request // can use it (implemented in the base class). freeConnection(con); } } // end of -- if (id != null) ... // Print an error message about the id error. Notice how // the 'else' block starts in this java tag and ends in // the next one (after the error message). else { Error: Invalid job identifier.

} // end of else -- error message. // ------------------------------------------------------ // Include the common footer. The footer is placed in the // /_private/jws_footer.html file and can be included // from any jhtml pages on the web site.