像这样的查询语句,在命令行中可以正确的查出数据,而使用jsp调用确没有了反应,实在是费解
String sql = "select * from StuInfo where KetiId in (select KtNum from KtInfo where TNum = 101)";我是使用的是mysql,使用Collection返回结果
String sql = "select * from StuInfo where KetiId in (select KtNum from KtInfo where TNum = 101)";我是使用的是mysql,使用Collection返回结果
或则你试试在servlet里面用用看,用ResultSet返回
// 获取该老师指导的学生
public Collection getStuByT(int t)
{
String sql = "select * from StuInfo where KetiId in (select KtNum from KtInfo where TNum = "+ t + ")";
Collection ret = new ArrayList();
try
{
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(sql); while (rs.next())
{
StuInfo temp = new StuInfo();
temp.setStuName(rs.getString("StuName"));
temp.setStuEmail(rs.getString("StuEmail"));
temp.setStuTel(rs.getString("StuTel"));
temp.setKetiId(rs.getInt("KetiId"));
temp.setStuInfo(rs.getString("StuInfo"));
temp.setKaitiIf(rs.getBoolean("KaitiIf"));
temp.setBiyeIf(rs.getBoolean("BiyeIf")); }
//con.close();
}
catch (SQLException e)
{
// TODO 自动生成 catch 块
e.printStackTrace();
}
return ret;
}jsp如下:<!--TeacherDo.java -->
<%@ include file="/include/import.jsp"%>
<jsp:useBean id="td" class="com.spliky.mywork.TeacherDo" scope="page" />
<%@ page contentType="text/html; charset=gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head> <body>
<p>
查看我指导的学生
</p>
<hr />
<%
int id = Integer.parseInt(request.getParameter("tNum")); Collection c = td.getStuByT(id);
Iterator it = c.iterator();
while (it.hasNext())
{
StuInfo tmp = (StuInfo) it.next(); %> <p>
姓名:
<%=tmp.getStuName()%>
</p>
<p>
课题:
<%=tmp.getKetiId()%>
</p>
<p>
Email:
<%=tmp.getStuEmail()%>
</p>
<p>
审核
</p>
<p>
导师评分:
</p>
<p>
评分
</p>
<hr />
<%}%> </body>
</html>