我正在尝试从mysql中检索数据。在给出正确的输入后,数据不会显示。我的jsp中的代码也不起作用,但catch块正确执行。你能建议我如何解决这个问题吗?
这是我的代码:
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.PreparedStatement"%>
<%@ page import="java.util.*" %>
<%
Connection con=null;
PreparedStatement pst=null;
ResultSet rs=null;
String url = "jdbc:mysql://localhost:3306/check2allowMultiQueries=true";
%>
<html>
<head>
<link href="cprofile.css" rel="stylesheet" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form name="view" method="POST">
<%
String z = request.getParameter("code");
String query="Select * from check2 where CODE='"+z+"';";
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/check 2", "root", "");
Statement st=con.createStatement();
rs = st.executeQuery(query);
while (rs.next()) {
%>
<table border="1">
<tr>
<td><%=rs.getString("NAME")%></td>>
<td><%=rs.getString("MEDIUM")%></td>
<td><%=rs.getString("CODE")%></td>
<td><%=rs.getString("ADD1")%></td>
<td><%=rs.getString("ADD2")%></td>
<td><%=rs.getString("CK")%></td>
<td><%=rs.getString("FK")%></td>
<td><%=rs.getString("BOARD")%></td>
</tr>
</table>
<%}
} catch(Exception e) {
out.println(e);
}
%>