<% @ page contentType="text/HTML. Charset=GB2312 "% & gt;
<% @ page import="Java. SQL. *" % & gt;
<body bgcolor=cyan>
<% Connection con;
Statement sql;
The ResultSet rs;
Try {class.forname (". Com. Mysql. JDBC Driver ");
}
The catch (Exception e) {}
Try {String uri="JDBC: mysql://127.0.0.1/warehouse";
String user="root";
String password="";
Con=DriverManager. GetConnection (uri, user, password);
//can also be written as con=DriverManager. GetConnection (uri + "? User=root& Password=");
SQL=con. CreateStatement ();
Rs=SQL. ExecuteQuery (" SELECT * FROM the product ");
Out. Print (" & lt; The table border=2 & gt;" );
Out. Print (" & lt; Tr>" );
Out. Print (" & lt; Th width=100 & gt;" + "product number");
Out. Print (" & lt; Th width=100 & gt;" + "name");
Out. Print (" & lt; Th width=50 & gt;" + "production date");
Out. Print (" & lt; Th width=50 & gt;" + "price");
Out. Print (" & lt;/TR>" );
While (rs), next ()) {
Out. Print (" & lt; Tr>" );
Out. Print (" & lt; Td & gt;" + rs. Get string (1) + "& lt;/td>" );
Out. Print (" & lt; Td & gt;" + rs. Get string (2) + "& lt;/td>" );
Out. Print (" & lt; Td & gt;" + rs. GetDate (" madeTime ") + "& lt;/td>" );
Out. Print (" & lt; Td & gt;" + rs. GetFloat (" price ") + "& lt;/td>" );
Out. Print (" & lt;/tr>" );
}
Out. Print (" & lt;/table>" );
Con. The close ();
}
The catch (SQLException e) {
Out. Print (e);
}
%>