<%@ page contentType
="text/html;charset=UTF-8" language
="java" %>
<html>
<head>
<title>主页
</title
>
</head
>
<body>
<%
Class
.forName("com.mysql.jdbc.Driver");
String url
= "jdbc:mysql://localhost:3306/book";
Connection connection
= DriverManager
.getConnection(url
,"root","root");
String sql
= "select * from user where username = ? and password = ?";
PreparedStatement pstm
= connection
.prepareStatement(sql
);
pstm
.setString(1,request
.getParameter("username"));
pstm
.setString(2,request
.getParameter("password"));
ResultSet rs
= pstm
.executeQuery();
while (rs
.next()){
out
.print(rs
.getString("username")+"-"+rs
.getString(2)+"<br>");
}
%>
</body
>
</html
>
转载请注明原文地址:https://blackberry.8miu.com/read-47182.html