这是什么意思? 这是JSP抛出的错误,也可能是WEB服务器中的定义不对,请贴出SOURCE. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <%@ page contentType="text/html; charset=GBK" %><%@ page language="java" import="java.sql.*,javax.sql.DataSource,javax.naming.InitialContext,ggboard.*" %><html><head><title>login</title></head><body bgcolor="#ffffff"><%String name=CodeFilter.toHtml(request.getParameter("name"));String passwd=CodeFilter.toHtml(request.getParameter("passwd"));DataSource ds = null;Connection con ;try { InitialContext ctx=new InitialContext(); ds=(DataSource)ctx.lookup("java:comp/env/jdbc/mysql"); con = ds.getConnection(); if (con == null) { System.out.println("不能获取数据库连接"); return; } } catch(Exception ex){ ex.printStackTrace(); throw new SQLException(ex.getMessage()); }ResultSet rs = null;ResultSetMetaData md = null;Statement stmt = null;String strSql ="SELECT count(*) FROM adminuser where passwd='"+passwd+"' and admin='"+name+"'";try {stmt = con.createStatement();rs = stmt.executeQuery(strSql);//md = rs.getMetaData();if(rs.getRow()>0){UserSession user=new UserSession();user.setUserId(name);user.setIsLogin(true);user.setLastLoginTime(new java.util.Date());user.setLogCount(10);session.setAttribute("userSession",user);response.sendRedirect("admin.jsp");}else{out.println("error password"+strSql+rs.getRow());}stmt.close();rs.close();}catch (SQLException e) {out.println(e.getMessage());}%></body></html>关键是有时可以执行,有时后,过一会就出现上述错误D:\Tomcat 5.0\conf\Catalina\localhost下的对应xml文件<?xml version='1.0' encoding='utf-8'?><Context docBase="D:/jsptest/board/board" path="/board" reloadable="true" workDir="d:/jsptest/board/j2src"><ResourceLink name="jdbc/mysql" global="jdbc/mysql" type="javax.sql.DataSourcer"/></Context>连接的是mysql 再问个问题,为什么我得到的rs.getRow()为0我在数据库里自己加了一条记录passwd=aaa,admin=aaa而且我是过将得到的strSql是SELECT count(*) FROM adminuser where passwd='aaa' and admin='aaa'在数据库里执行此sql明明有结果为什么rs.getRow()为0? HighCharts导出中文是乱码 jsp web开发,乱码问题 怎么让这个圆只画一次 jsp网页中如何监听(接收)udp发送的数据流 跪球一个jsp+Mysql 论坛系统 !!!! 急 如何将JFreeChart生成的图片转换到web页面上? DBCP连接池的问题 jsp如何在win2000server下如何设置成默认网站 在使用clob字段时候,spring配置之后报此异常,事物也以及配置 求 用JB开发代码,可以直接用import aa.aa.*这种方法来调用已经编译好的Class文件吗? 调试JSP的问题!
<%@ page language="java" import="java.sql.*,javax.sql.DataSource,javax.naming.InitialContext,ggboard.*" %>
<html>
<head>
<title>
login
</title>
</head>
<body bgcolor="#ffffff">
<%
String name=CodeFilter.toHtml(request.getParameter("name"));
String passwd=CodeFilter.toHtml(request.getParameter("passwd"));
DataSource ds = null;
Connection con ;
try
{
InitialContext ctx=new InitialContext();
ds=(DataSource)ctx.lookup("java:comp/env/jdbc/mysql");
con = ds.getConnection();
if (con == null) {
System.out.println("不能获取数据库连接");
return;
}
}
catch(Exception ex){
ex.printStackTrace();
throw new SQLException(ex.getMessage());
}ResultSet rs = null;
ResultSetMetaData md = null;
Statement stmt = null;
String strSql ="SELECT count(*) FROM adminuser where passwd='"+passwd+"' and admin='"+name+"'";
try {
stmt = con.createStatement();
rs = stmt.executeQuery(strSql);
//md = rs.getMetaData();
if(rs.getRow()>0)
{
UserSession user=new UserSession();
user.setUserId(name);
user.setIsLogin(true);
user.setLastLoginTime(new java.util.Date());
user.setLogCount(10);
session.setAttribute("userSession",user);
response.sendRedirect("admin.jsp");
}
else
{
out.println("error password"+strSql+rs.getRow());
}
stmt.close();
rs.close();
}
catch (SQLException e) {
out.println(e.getMessage());
}
%>
</body>
</html>关键是有时可以执行,有时后,过一会就出现上述错误
D:\Tomcat 5.0\conf\Catalina\localhost下的对应xml文件<?xml version='1.0' encoding='utf-8'?>
<Context docBase="D:/jsptest/board/board" path="/board" reloadable="true" workDir="d:/jsptest/board/j2src">
<ResourceLink name="jdbc/mysql" global="jdbc/mysql" type="javax.sql.DataSourcer"/>
</Context>连接的是mysql
我在数据库里自己加了一条记录passwd=aaa,admin=aaa
而且我是过将得到的strSql是
SELECT count(*) FROM adminuser where passwd='aaa' and admin='aaa'
在数据库里执行此sql明明有结果
为什么rs.getRow()为0?