当前位置: 代码迷 >> Java Web开发 >> 投票的问题
  详细解决方案

投票的问题

热度:202   发布时间:2006-12-23 20:53:49.0
投票的问题

代码都贴出来拉。。就是为什么不循环呀?
每次都是就显示一个投票结果。。。。
是那的问题???第一回做。。。


<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page language="java" import="java.sql.*"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
--%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>投票结果</title>
<% out.println("jsptoupiao");
try
{
Connection con=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:music","sa","");

PreparedStatement s= con.prepareStatement("select * from music where nume>0 order by nume desc");
ResultSet r=s.executeQuery();%>
<table border=2>
<%

while(r.next()){
%>


<tr>
<td><%=r.getString("musicname")%></td>
<td><img src=images/dot.gif height=13 width=<%=r.getString("nume")%>></td>
<td><%=r.getString("nume")%></td>
</tr>


<% }%>
</table><%
}

catch(Exception e)
{}

%>
</head>
<body>



<%--
This example uses JSTL, uncomment the taglib directive above.
To test, display the page like this: index.jsp?sayHello=true&name=Murphy
--%>
<%--
<c:if test="${param.sayHello}">
<!-- Let's welcome the user ${param.name} -->
Hello ${param.name}!
</c:if>
--%>

</body>
</html>

[此贴子已经被作者于2006-12-23 20:54:45编辑过]

搜索更多相关主题的帖子: page  target  java  blank  

----------------解决方案--------------------------------------------------------
你的数据库里面有几条记录
----------------解决方案--------------------------------------------------------

3条。。。。大家看看是代码的问题还是那的问题。。。

[此贴子已经被作者于2006-12-23 23:36:02编辑过]


----------------解决方案--------------------------------------------------------

<td><img src="images/dot.gif" height=13 width=<%=r.getString("nume")%>></td>
除了这里加个引号外,其它没发现什么问题


----------------解决方案--------------------------------------------------------
有没有双引号都一样

为什么不循环,你自己查查咯
select * from music where nume>0 order by nume desc
nume>0的记录是不是只有一条呀?
----------------解决方案--------------------------------------------------------
好一个JavaEE5

----------------解决方案--------------------------------------------------------

不是。。。在查询分析器里看拉。。。。还是3条呀。。。
真的没问题???。。我再看看去。。。


----------------解决方案--------------------------------------------------------
在while前面加了2个r.next可以看到最后面的哪个投票结果。。。不过还是只有一条。。。。。。。。郁闷呀。。到底是那的错??

[此贴子已经被作者于2006-12-24 13:25:37编辑过]



----------------解决方案--------------------------------------------------------
catch(Exception e){
out.print(e.ToString())
}

加个这个,看看有没有错
----------------解决方案--------------------------------------------------------
java.sql.SQLException: No data found   为什么呀??查询分析器里有的呀。。。要是把next直接只到地2,3条也是可以输出的呀。。。。。不过还是只有1条。。。
----------------解决方案--------------------------------------------------------
  相关解决方案