日期:2014-05-18  浏览次数:20817 次

jsp+mysql的很简单的问题
<%@ page contentType="text/html;charset=GB18030"%>
<%@ page language="java" import="java.sql.*" %>
<%
String sUsername,sPassword;
sUsername = request.getParameter("username");
sPassword = request.getParameter("password");
String chaxunQuery = "select * from user where username='"+sUsername+"',password='"+sPassword+"'";

Connection conn=null;
Statement stmt=null;
ResultSet rs=null;


try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost/lijiang?user=root&&password=16331984");
stmt = conn.createStatement();
rs = stmt.executeQuery(chaxunQuery);
if(rs.next())
{
response.sendRedirect("choose.html");
}
else
{
response.sendRedirect("index.html");
}
}
catch (SQLException ex)
{
ex.printStackTrace();
response.sendRedirect("index.html");
return;
}
finally
{
rs.close();
stmt.close();
conn.close();
}


%>


我这个页面有没有错,我第一个页面,就是一个普通的HTML,有两个输入框,一个用户名,和一个密码,然后发过这里,进行一下处理,怎么是出错。


--------------------------------
以下内容为自动编辑的内容,并非楼主的发贴内容,此仅用于显示而已,并无任何其他特殊作用
楼主【futurefire】截止到2008-08-04 22:14:09的历史汇总数据(不包括此帖):
发帖的总数量:3 发帖的总分数:170 每贴平均分数:56  
回帖的总数量:11 得分贴总数量:4 回帖的得分率:36%  
结贴的总数量:3 结贴的总分数:170  
无满意结贴数:0 无满意结贴分:0  
未结的帖子数:0 未结的总分数:0  
结贴的百分比:100.00% 结分的百分比:100.00%  
无满意结贴率:0.00 % 无满意结分率:0.00 %  
敬礼!
取消马甲机器人,请点这里:http://www.java2000.net/mycsdn/robotStop.jsp?usern=futurefire

------解决方案--------------------
"select * from user where username='" + sUsername + " and password = '" + sPassword + "'";