2个回答
展开全部
<%@ page language="java" contentType="text/html;charset=gb2312" import="java.sql.*"%>
<%@ page import="com.mysql.jdbc.Driver" %>
<%! String username,password;%>
<% username=request.getParameter("user1");
password=request.getParameter("password1");
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch(ClassNotFoundException e){out.print("0");}
try
{
Connection con=java.sql.DriverManager.getConnection("jdbc:mysql://localhost/regi","root","");
Statement stmt=con.createStatement();
String sql="SELECT * FROM regeister1";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{
if(username.equals(rs.getString(1))&password.equals(rs.getString(2))){%>
<jsp:forward page="../regeister/regeister.html"></jsp:forward>
<%
}
}
rs.close();
stmt.close();
con.close();
}
catch(Exception e){out.print("2");}
%>
这是代码 还需要包mysql-connector-java-5.0.5-bin.jar 就行了
<%@ page import="com.mysql.jdbc.Driver" %>
<%! String username,password;%>
<% username=request.getParameter("user1");
password=request.getParameter("password1");
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}
catch(ClassNotFoundException e){out.print("0");}
try
{
Connection con=java.sql.DriverManager.getConnection("jdbc:mysql://localhost/regi","root","");
Statement stmt=con.createStatement();
String sql="SELECT * FROM regeister1";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{
if(username.equals(rs.getString(1))&password.equals(rs.getString(2))){%>
<jsp:forward page="../regeister/regeister.html"></jsp:forward>
<%
}
}
rs.close();
stmt.close();
con.close();
}
catch(Exception e){out.print("2");}
%>
这是代码 还需要包mysql-connector-java-5.0.5-bin.jar 就行了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询