我收到错误HTTP状态404的描述:请求的资源不可用。我不知道出了什么问题! 我在MySql Workbench中使用netbeans,我用一个表(lista)创建了一个模式(spesa)。
<%@page import="java.sql.ResultSetMetaData"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.util.Date"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.DriverManager"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Lista della spesa</h1>
<%
Class.forName("com.mysql.jdbc.Driver");
String dburl = "jdbc:mysql://localhost/spesa?user=spesa&password=spesa";
Connection con = DriverManager.getConnection(dburl);
Statement st = con.createStatement();
String sql = "SELECT voce,data,ordine FROM lista ORDER BY ordine";
ResultSet res = st.executeQuery(sql);
out.println ("<table>");
while (res.next () ) {
String voce = res.getString("voce");
Date data = res.getDate("data");
int ordine = res.getInt("ordine");
out.println("<tr><td>"
+ voce + "</td><td>"
+ data + "</td><td>"
+ ordine + "</td></tr>");
}
out.println ("</table>");
st.close ();
con.close ();
%>
</body>