关于JSP连接数据库查询的问题,大虾请进
为什么在本地服务器测试的时候没有反应呢?也不报错.我是想从oracle的数据库里验证登录的用户名和密码对不对,请大家帮帮忙啊.
下面的代码应该怎么修改呢?
<%@ page language= "java " import= "java.io.*,java.sql.*,javax.sql.* ,javax.naming.* "%>
<%@ page contentType= "text/html;charset=gb2312 "errorPage= "error.jsp " %>
<%
String sDBDriver = "oracle.jdbc.driver.OracleDriver "; //数据库连接驱动
String sConnStr = "jdbc:oracle:@192.168.74.225:1521:QXZLDB ";
Connection conn = null;
ResultSet rs = null; //查询语句返回结果集
Statement stmt = null; //查询语句(sql语句)
try
{
Class.forName(sDBDriver);
conn = DriverManager.getConnection(sConnStr, "QX ", "QX ");
stmt = conn.createStatement();
rs = stmt.executeQuery( "select * from QX_YHXXB where YH_MC= 'admin 'AND YHMM= ' '1 ");
if (!rs.next())
{
%>
<jsp:forward page= "fail.jsp "> </jsp:forward>
<%
}
else
{
%>
<jsp:forward page= "welcome.jsp "> </jsp:forward>
<%
}
//登录成功,可以跳转
rs.close();
}
catch(Exception e)
{
out.println(e);
}
%>
[解决办法]
select * from QX_YHXXB where YH_MC= 'admin 'AND YHMM= ' '1
??笔误??