求救啊~~紧急求救各位同廖 你在jsp中是否引入了dbconn所在的包?估计你是没有引入.或者你userBean也可以. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 引用了啊<%@ page import = "nona.db.dbconn" %><jsp:useBean id="DbConn" class="nona.db.dbconn" scope="session"/><jsp:setProperty name="DbConn" property="*"/>我把rs1.getString(1)去掉就没错了,估计是rs有问题 you'd better use staticpublic static Connection conn;and then close conn after calling public static Connection conn;一样不管用 把你的jsp文件改成这样试一下。<% String username=request.getParameter("username"); String pws=request.getParameter("pws"); String sql="select * from duser where (f11='"+username+"')"+" and (f19='"+pws+"')"; DbConn.getconnection(); ResultSet rs1=DbConn.selectSQL(sql); while(rs1.next()){ rs1.getString(1); }%> public Vector runSQLQuery(String strSQL){ java.sql.ResultSet rs = null; java.util.Vector vResult = null; try { Statement stmt=conn.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); rs = stmt.executeQuery(strSQL); int columnCount = rs.getMetaData().getColumnCount(); vResult = new Vector(); while(rs.next()) { java.util.Vector vTemp = new Vector(); for(int i = 0;i< columnCount;i++) { String sTemp = rs.getString(i+1); vTemp.addElement(sTemp== null ? "" : Global.transOut(sTemp.trim())); } vResult.addElement(vTemp); } rs.close(); } catch(SQLException e1) { } finally { }return vResult;} so? output the sql sentence which it runs.copy it and run it in database to check if it can get result icecloud:output的sql能运行,并且能得到一条记录, lucky_yeti说的“我的conn是在jsp页上生成的,而我的selectSQL是需要java文件中的conn”有没有关系啊 icecloud:我就把.java中的public Connection conn改成了public static Connection conn不行啊 按理说应该不会,如果库没有连接那么这句ResultSet rs1=DbConn.selectSQL(sql);应该出错,为了验证一下,你可以把连接数据库的代码放到java文件中,jsp中只调用DbConn.selectSQL(sql);再试试看。 每次请求Session都不一样?我想知道是怎么一回事? 关于corba和web service tomcat虚似主机servlet404,本地调试没问题的. hibernate简单问题 在jbuilder9中编译后文件输出问题,在线等待,解决即给分 计数器不自动增加值? jsp中有没有办法用中文路径呢 jsp+oracle insert库里是乱码,怎么解决? 如何实现通过连接将表单数据提交到下一页面 在Struts中使用自定义标签,如何取参数值! 诚聘英才 大家的网站完活后都用什么来发布啊?用什么服务器啊?有没有和iis整合的啊?
<%@ page import = "nona.db.dbconn" %>
<jsp:useBean id="DbConn" class="nona.db.dbconn" scope="session"/>
<jsp:setProperty name="DbConn" property="*"/>
我把rs1.getString(1)去掉就没错了,估计是rs有问题
public static Connection conn;and then close conn after calling
<% String username=request.getParameter("username");
String pws=request.getParameter("pws");
String sql="select * from duser where (f11='"+username+"')"+" and (f19='"+pws+"')";
DbConn.getconnection();
ResultSet rs1=DbConn.selectSQL(sql);
while(rs1.next()){
rs1.getString(1);
}%>
{
java.sql.ResultSet rs = null;
java.util.Vector vResult = null;
try
{
Statement stmt=conn.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(strSQL); int columnCount = rs.getMetaData().getColumnCount();
vResult = new Vector(); while(rs.next())
{
java.util.Vector vTemp = new Vector();
for(int i = 0;i< columnCount;i++)
{
String sTemp = rs.getString(i+1);
vTemp.addElement(sTemp== null ? "" : Global.transOut(sTemp.trim()));
} vResult.addElement(vTemp);
} rs.close(); }
catch(SQLException e1)
{ }
finally
{
}return vResult;}
copy it and run it in database to check if it can get result
这句ResultSet rs1=DbConn.selectSQL(sql);
应该出错,
为了验证一下,你可以把连接数据库的代码放到java文件中,
jsp中只调用DbConn.selectSQL(sql);
再试试看。