This Text file is old! In a 🏛️Museum, an unsorted archive of (user-)pages. (Saved from Geocities in Oct-2009. The archival story: oocities.org)
--------------------------------------- (To 🚫report any bad content: archivehelp @ gmail.com)
<%@ page contentType="text/html;charset=windows-1252"%> <%@ page import="mypackage.*,java.sql.ResultSet" %> Without The Tag Library

We can get the same results without the tag library, but the code so so much more complex, difficult to read and maintain.


<%! ResultSet resultSet; java.util.Collection columnTitles; String queryString="SELECT * FROM USER_INFO"; javax.sql.DataSource ds = null; java.sql.Connection conn; String JDBCClass="COM.cloudscape.core.RmiJdbcDriver"; String userName="APP"; String password=""; String connectionURL="jdbc:rmi://localhost:1099/jdbc:cloudscape:CloudscapeDB;create=true"; /** * displays the actual table * * @see #displayTitles * @param JspWriter out writer from the page the tag is in * @param ResultSet rs java.sql.ResultSet from the executed query * @param Collection t uses a collection of strings as the input * @exception NONE * @return void */ void writeTheOutput( JspWriter out ) { try { if ( resultSet == null ) { out.print("EMPTY RESULT SET"); return; } out.print("
"); out.print(""); out.print(""); // from the meta data, get the title(s) java.sql.ResultSetMetaData rsMD = resultSet.getMetaData(); StringBuffer b = new StringBuffer(); String d; int colCount = rsMD.getColumnCount(); b.append(""); for (int i = 1; i <= colCount; i++) { b.append(""); } b.append(""); // Write the title(s) out.print(b.toString()); // Loop thru the resultSet and write the data from the database while ( resultSet.next() ) { out.print(""); for (int i = 0; i < colCount; i++) { out.print(""); } out.print(""); } } catch(Exception e) { e.printStackTrace(); } finally { try { out.print("
" + rsMD.getColumnName(i) + "
" + resultSet.getObject(i+1).toString() + "
"); } catch (Exception e) {} try { out.print("
"); } catch (Exception e) {} } } void writeTheTable( JspWriter out ) throws javax.servlet.ServletException { try { // if there is no dataSource defined, then I need all the other params if ( ds == null ) { Class.forName(JDBCClass); conn = java.sql.DriverManager.getConnection(connectionURL, userName, password); } else { conn = this.ds.getConnection(); } // Execute the SQL Query... java.sql.Statement stmt = conn.createStatement(); resultSet = stmt.executeQuery( queryString); out.print("
" + resultSet); writeTheOutput( out ); } catch (Exception e) { throw new javax.servlet.ServletException(e.toString()); } finally { try { if (resultSet != null) resultSet.close(); } catch ( Exception e) {}; try { if (conn != null) conn.close();} catch ( Exception e) {}; } } %> <% writeTheTable( pageContext.getOut() ); %>

Text file Source (historic): geocities.com/asaund6835/Java_tutorial/src

geocities.com/asaund6835/Java_tutorial
geocities.com/asaund6835

(to report bad content: archivehelp @ gmail)