Java Reference
In-Depth Information
<HTML> C View specific HTML
<HEAD>
<TITLE>Message Board Posts</TITLE>
</HEAD>
<BODY BGCOLOR=#C0C0C0>
<H1>All Messages</H1>
<P>
<TABLE border="1">
<TR>
<TD>Subject</TD>
<TD>Author</TD>
<TD>Board</TD>
</TR>
<% D Model specific database access
// Establish a connection
try {
Class.forName ("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
// connect with default id/password
connection = DriverManager.getConnection (url);
// set and execute SQL statement
statement = connection.createStatement();
result = statement.executeQuery
("SELECT subject, author, board from posts");
// print the results
// retrieve data from the database and print on the result page
while (result.next()) {
out.println("<TR> <TD>" + result.getString(1) + "</TD>");
out.println("<TD>" + result.getString(2) + "</TD>");
out.println("<TD>" + result.getString(1) + "</TD></TR>");
}
result.close();
statement.close();
connection.close();
} catch (Throwable theException) {
out.println("Connection or output print failed.");
}
%>
</TABLE> E View specific HTML
<P>
</BODY>
</HTML>
Search WWH ::




Custom Search