<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8" import="java.sql.*" %>
<!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=ISO-8859-1">
<title>用户管理</title>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
width:521px;
height:713px;
z-index:1;
left: 157px;
top: 38px;
font-color:#FFFFFF;
}
-->
</style>
</head>
<body background="images/bg-0300.gif"><% Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
try{
String driver="sun.jdbc.odbc.JdbcOdbcDriver";
String src="jdbc:odbc:Database";
String sql="select sum(total) from SalesOrder";
Class.forName(driver);
conn=DriverManager.getConnection(src);
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
%>
<div id="apDiv1">
<table width="200px" align="center" border="1" cellspacing="0px" cellpadding="1px" bordercolor="#0096e1">
<tr bgcolor="#0096e1">
<th >月销售金额 </th>
</tr>
<%
while(rs.next()){
String total=rs.getString("total");
%>
<tr>
<td align="center"><%=total %></td>
</tr>
<% }
}catch(Exception e){
e.printStackTrace();
}finally{
if(rs!=null)rs.close();
if(stmt!=null)stmt.close();
if(conn!=null)conn.close();
}
%>
</table>
</div>
</body>
</html>
pageEncoding="utf-8" import="java.sql.*" %>
<!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=ISO-8859-1">
<title>用户管理</title>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
width:521px;
height:713px;
z-index:1;
left: 157px;
top: 38px;
font-color:#FFFFFF;
}
-->
</style>
</head>
<body background="images/bg-0300.gif"><% Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
try{
String driver="sun.jdbc.odbc.JdbcOdbcDriver";
String src="jdbc:odbc:Database";
String sql="select sum(total) from SalesOrder";
Class.forName(driver);
conn=DriverManager.getConnection(src);
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
%>
<div id="apDiv1">
<table width="200px" align="center" border="1" cellspacing="0px" cellpadding="1px" bordercolor="#0096e1">
<tr bgcolor="#0096e1">
<th >月销售金额 </th>
</tr>
<%
while(rs.next()){
String total=rs.getString("total");
%>
<tr>
<td align="center"><%=total %></td>
</tr>
<% }
}catch(Exception e){
e.printStackTrace();
}finally{
if(rs!=null)rs.close();
if(stmt!=null)stmt.close();
if(conn!=null)conn.close();
}
%>
</table>
</div>
</body>
</html>
解决方案 »
- jsp数据库查询问题
- DAO 里的 findByExample 方法什么意思?怎么用?...在线等
- 求救,乱码问题
- struts高手们请帮我解释一下:什么时候适合使用动态form,什么情况下不适合使用动态form
- 问一下关于smartupload组件的问题
- 怎么取的图片的长宽
- 高分求助
- 想认识一些开发JAVA方面程序的朋友。[email protected](MSN)
- $$$$$虚心请教个关于IFRAME自动检测并刷新的问题!感激不尽!
- 在一个jsp页面中怎样提交本页面内容和用showModalDialog打开窗口返回的值
- jsp怎样实现一个C++程序的后台编译
- java.lang.IllegalStateException怎么解决?
改成rs.getString("sum(total)")或rs.getString(1);试试
可能选择出来的数据的列名变了