我有一个登陆网站的JSP与数据库连接的问题

来源:百度知道 编辑:UC知道 时间:2024/05/22 19:37:48
<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<%@ page import="java.sql.*" %>
<html>
<head><title>Conn</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
String url ="jdbc:mysql://127.0.0.1:3306/test?user=root&password=6629779&useUnicode=true&characterEncoding=GB2312" ;
Connection connection= DriverManager.getConnection(url);
Statement statement=connection.createStatement();

String uid = request.getParameter("uid");
String upwd = request.getParameter("upwd");
String sql="select *from test where name='"+uid+"'and password='"+upwd+"'";
ResultSet rs = statement.executeQuery(

多查看资料啊,总是有的,我就不复制了,也是我回答的同样的问题
http://zhidao.baidu.com/question/90231466.html

if(rs.next()) {
response.sendRedirect("/denluwangzhan.jsp");
}
else
{
response.sendRedirect("/j3.jsp");
}
在网上很多介绍的,这些简单的问题,你还是自己直接找的好。