<% @ page import="Java. SQL. *" % & gt;
<meta HTTP - equiv="content-type" Content="text/HTML. charset=UTF-8">
<body>
<%
//query name
String selectBookname=request. The getParameter (" txtSelect ");
% & gt;
<%
//connect to the database of the five parameters
String driverClass=". Com. Mysql. Cj. JDBC Driver ".
String serverIp="localhost";
String databaseName="zhbit";
String userName="root";
String PWD="ax191823503";
String jdbcUrl="JDBC: mysql://" + serverIp + + + "databaseName" : 3306/"? ServerTimezone=Asia/Shanghai& UseSSL=true ";
String SQL="select * from test3";
//read the JDBC
Class.forname (driverClass);
//links database
Connection con=DriverManager. GetConnection (jdbcUrl, userName and PWD).
//if empty, instead represent the current state of the query, query all the content of the
PreparedStatement ps;
If (selectBookname==null) {
//whether the query text box with content, if not all of the information query execution
Ps=con. PrepareStatement (SQL);
} else {
//if there is, according to the inside of the contents of a text box in the database according to the query name
Ps=con. PrepareStatement (" select * from book where bookname like?" );
Ps. SetString (1, '%' + selectBookname + '%');
}
//the ResultSet variable is a pointer to a database, is essentially not save any data, execute the query
The ResultSet rs=ps. ExecuteQuery ();
//a Boolean flag=rs. Next ();//determine whether return pointer still can continue to move down
//show the serial number
int i=1;
While (rs), next ()) {
% & gt;
<%
}
% & gt;
<%
Ps. The close ();
Con. The close ();
% & gt;