Here is the code of a JavaServer page:
<%@page language="java" import="java.sql.*" %>
<%
String tMaxPriceString = "1000000000000.0";
if (request.getParameter("testprice") != null)
{
tMaxPriceString = (String)request.getParameter("testprice");
}
final Driver tDriver =
(Driver)Class.forName("org.gjt.mm.mysql.Driver").newInstance();
final Connection tConnection = DriverManager.getConnection(
"jdbc:mysql://www.dur.ac.uk/Pdcl0bjc_prices", "", "");
final PreparedStatement tPreparedStatement =
tConnection.prepareStatement(
"SELECT * FROM consum WHERE price < "
+ tMaxPriceString + " ORDER by price");
tPreparedStatement.setQueryTimeout(0);
final ResultSet tResultSet = tPreparedStatement.executeQuery();
%>
<html>
<head>
<title>Access to the prices database</title>
</head>
<body bgcolor="#FFFFFF">
<table>
<%
while (tResultSet.next())
{
%>
<tr>
<td>
<%= ((tResultSet.getObject("price")!=null)?tResultSet.getObject("price"):"") %>
</td>
<td>
<%= ((tResultSet.getObject("goods")!=null)?tResultSet.getObject("goods"):"") %>
</tr>
<%
}
%>
</table>
</body>
</html>
<%
tResultSet.close();
tConnection.close();
%>