<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
Insert title here
<%@ page language="java" import="java.sql.*" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
Insert title here <% String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver"; String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName = test"; String userName="sa"; String userPwd="123456"; Class.forName(driverName); Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql = "select * from Table_1 where [用户名]=? and [密码]=?"; PreparedStatement pstmt = dbConn.prepareStatement(sql); request.setCharacterEncoding("UTF-8"); String user = request.getParameter("username"); String pass = request.getParameter("pass"); pstmt.setString(1, user); pstmt.setString(2, pass); ResultSet rs = pstmt.executeQuery(); if(rs.next()) { %>
登陆成功!
<% } else { %>
登陆失败!
<% } %>