javabean的问题
我在做设计时遇到以下情况,我用JSP页面调用javabean和数据库相连,javabean成功的通过编译,生成了*.class文件,数据库方面也没问题,单用JSP页面连接时能成功显示结果,可是用javabean时没错误提示,只是不输出结果,郁闷中…………代码如下:
xianlu.jsp
<%@ page import="java.lang.*, *, java.sql.*, java.util.*" contentType="text/html;charset=gb2312" %>
<%@ page import="bus.chaxun.*"%>
<html>
<body>
<p class="STYLE1">烟台公交线路查询:</p>
<jsp:useBean id="base" class="bus.chaxun.Xianlu" scope="session"/>
<jsp:setProperty name="base" property="busname" param="busname"/>
<form method="post" action="">
<p>输入公交线路名称:
<input type="text" name="busname" />
(如:46路)</p>
<p>
<input type="submit" name="Submit" value="点击查询" />
</p>
</form>
<jsp:getProperty name="base" property="busname"/>路车经过的站点为:<br>
<jsp:getProperty name="base" property="queryResult"/>
</body>
</html>
xianlu.java
package bus.chaxun;
import java.sql.*;
public class Xianlu
{
String busname;
int i;
StringBuffer queryResult;
public Xianlu()
{
queryResult=new StringBuffer();
try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();}
catch(Exception e){ }
}
public void setBusname(String s)
{
busname=s.trim();
queryResult=new StringBuffer();
}
public String getBusname()
{
return busname;
}
public StringBuffer getQueryResult()
{
String condition="select * from bustable where busname="+busname+"";//bustable为表
queryResult=f(condition);
return queryResult;
}
private StringBuffer f(String condition)
{
StringBuffer str=new StringBuffer();
try{String url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=busdate"; //busdate为数据库
String user="sa";
String password="";
Connection conn=DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery(condition);
for(i=2;i<92;i++)
{
str.append(" "+rs.getString(i)+" ");
}
rs.close();
stmt.close();
conn.close();
}catch(SQLException e){System.out.println(e);}
return str;
}
}
望高手指点…………