[求助]桥连正确,直连失败
index.jsp<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<title>
index
</title>
<script type="text/javascript" language="javascript">
<!--
function check(){
var name = document.frm.name.value;
var pass = document.frm.pass.value;
if(name == ""){
alert("用户名不能为空!");
return false;
}else if(pass == ""){
alert("密码不能为空!");
return false;
}else{
return true;
}
}
//-->
</script>
</head>
<body bgcolor="#ffffff">
<h1>
欢迎光临本网站
</h1>
<form action="login.jsp" name="frm" method="GET" onsubmit="return check()">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="name"/></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="pass"/></td>
</tr>
<tr>
<td><input type="submit" value="提交"/></td>
<td><input type="reset"/></td>
</tr>
</table>
<br />
<input type="button" value="注册新用户" onclick="location.href='register.jsp'"/>
</form>
</body>
</html>
login.jsp
<%@ page contentType="text/html; charset=GBK" import="java.sql.*" %>
<html>
<head>
<title>
login
</title>
</head>
<%
String dirver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url = "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName = webDB";
String userName = "sa";
String password = "";
String name = request.getParameter("name");
//String aa = new String(name.getBytes("iso8859-1"),"gb2312");
String pass = request.getParameter("pass");
//String bb = new String(pass.getBytes("iso8859-1"),"gb2312");
String sql = "select * from userInformation where userName = '"
+name+"' and [password] = '"+pass+"'";
try{
Class.forName(dirver);
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Connection con = DriverManager.getConnection("jdbc:odbc:test");
Connection con = DriverManager.getConnection(url,userName,password);
Statement stn = con.createStatement();
ResultSet rs = stn.executeQuery(sql);
if(rs.next()){
response.sendRedirect("success.jsp");
}else{
response.sendRedirect("fail.jsp");
}
}catch(Exception e){
}
out.print(name);
out.print("<br>");
out.print(pass);
%>
<body bgcolor="#ffffff">
</body>
</html>
为什么同样的程序桥连就能转到相应的页面
而直连却不能呢?请大家指点?
当直连时,红色的代码不能得到执行