日期:2014-05-18  浏览次数:20694 次

求助:想将数据库里的信息在网页上以表格形式显示
请教各位,我想把数据库里的信息在网页上以表格形式显示,可是不成功,源代码是这样的:
<table border=1 cellspacing=0 width="90%" bordercolor="#006699" align=center class=listFrame id="maintable">
<tr>
<td height=5><div align="center">序号
</div></td>
<td height=5>
<div align="center">剧场名称
</div></td>
<td height=5>
<div align="center">名称
</div></td>
<td height=5>
<div align="center">品牌
</div></td>
<td height=5>
<div align="center">产地
</div></td>
<td height=5>
<div align="center">型号
</div></td>
<td height=5>
<div align="center">数量
</div></td>
<td height=5>
<div align="center">外型尺寸
</div></td>
<td height=5>
<div align="center">重量
</div></td>
<td height=5>
<div align="center">规格说明(频率响应,灵敏度,阻抗,承受功率)
</div></td>
<td height=5>
<div align="center">位置
</div></td>
</tr>
<%
final String DBDRIVER = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; //数据库驱动程序
final String DBURL = "jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=theater"; //URL

Connection conn = null ; 
ResultSet rs = null ;  
Statement st=null;  
PreparedStatement stat=null;
try
{
Class.forName(DBDRIVER); //装载驱动程序
conn = DriverManager.getConnection(DBURL,"sa","admin") ;
st=conn.createStatement();  
rs = st.executeQuery("select * from sound_box") ;
while(rs.next())
{
if(rs.getString(2).equals(session.getAttribute("theater_name")))
{
String boxID=rs.getString("boxID");
String theater_name=rs.getString("theater_name");
String box_name=rs.getString("box_name");
String box_brand=rs.getString("box_brand");
String box_area=rs.getString("box_area");
String box_model=rs.getString("box_model");
String box_num=rs.getString("box_num");
String box_size=rs.getString("box_size");
String box_weight=rs.getString("box_weight");
String box_spec=rs.getString("box_spec");
String box_location=rs.getString("box_location");
%>
<!--表格行操作及显示-->
<tr>
<td height=5>
<div align="center"><%=boxID%>
</div></td>
<td height=5>
<div align="center"><%=theater_name%>
</div></td>
<td height=5>
<div align="center"><%=box_name%>
</div></td>
<td height=5>
<div align="center"><%=box_brand%>
</div></td>
<td height=5>
<div align="center"><%=box_area%>
</div></td>
<td height=5>
<div align="center"><%=box_model%>
</div></td>
<td height=5>
<div align="center"><%=box_num%>
</div></td>
<td height=5>
<div align="center"><%=box_size%>
</div></td>
<td height=5>
<div align="center"><%=box_weight%>
</div></td>
<td height=5>
<div align="center">