哪为高手帮忙看一下,谢谢<%@ include file="purview.jsp"%>
<%@ page language = "java" contentType = "text/html;charset=gb2312"%>
<%@ page import = "java.sql.*"%>
<%@ page import = "javax.naming.*"%>
<%@ page import = "javax.sql.DataSource"%>
<%@ page import="java.text.DecimalFormat"%>
<html>
<head>
<LINK href="../css/main.css" type="text/css" rel=stylesheet>
<LINK href="../css/rubbing.css" type="text/css" rel=stylesheet>
<link rel="stylesheet" href="../css/style.css" type="text/css">
</head>
<body background="../images/bg.jpg" >
<%
String strGClass = request.getParameter("GClass");
if (strGClass == null || strGClass == "")
strGClass = "-1";
String iGName = request.getParameter("GName");
if (iGName == null || iGName == "")
iGName = "";
iGName = new String(iGName.getBytes("ISO8859-1"));
String iGCode = request.getParameter("GCode");
if (iGCode == null || iGCode == "")
iGCode = "";
iGCode = new String(iGCode.getBytes("ISO8859-1"));
int iGClass = Integer.parseInt(strGClass);
try{
Context initCtx = new InitialContext();
DataSource ds=null;
ds = (DataSource) initCtx.lookup("java:comp/env/jdbc/webTbd");
Connection conn = ds.getConnection();
CallableStatement cstmt = null;
ResultSet rs = null;
String sql = null;
cstmt = conn.prepareCall("{?=call t_LGoodsPrice(?, ?, ?)}");
cstmt.registerOutParameter(1, java.sql.Types.INTEGER);
cstmt.setInt(2, iGClass);
cstmt.setString(3, iGName);
cstmt.setString(4, iGCode);
rs = cstmt.executeQuery();
/*××××××××××××××××××××××××分页××××××××××××××××××××××*/
int intPageSize; //一页显示的记录数
int intRowCount; //记录总数
int intPageCount; //总页数
int intPage; //待显示页码
String strPage;
int i;
//设置一页显示的记录数
intPageSize=1; //MySelf=Request.ServerVariables("PATH_INFO");
//取得待显示页码
strPage=request.getParameter("page");
if(strPage==null)//表明在QueryString中没有Page这一个参数,此时显示第一页数据
intPage=1;
else{//将字符串转换成整型
intPage=java.lang.Integer.parseInt(strPage);
if(intPage<1) intPage=1;
}
out.println(rs);
//获取记录总数
rs.last();
intRowCount=rs.getRow();
//记算总页数
intPageCount =(intRowCount+intPageSize-1)/intPageSize;
//调整待显示的页码
if(intPage>intPageCount) intPage=intPageCount;
if(intPageCount>0)
//将记录指针定位到待显示页的第一条记录上
rs.absolute((intPage-1)*intPageSize+1);
//显示数据
i=0;
%>
<table border="1" width="100%" align="center" cellspacing="0" cellpadding="0" class="f_sm">
<%
out.println("<tr><td align=center><STRONG>货品编码</STRONG></td>");
out.println("<td align=center><STRONG>货品名称</STRONG></td>");
out.println("<td align=center><STRONG>单位</STRONG></td>");
out.println("<td align=center><STRONG>库存数量</STRONG></td>");
out.println("<td align=center><STRONG>售货价</STRONG></td>");
out.println("<td align=center><STRONG>提前订货期(天)</STRONG></td></tr>");
DecimalFormat df = new DecimalFormat("#0.00");
while(i<intPageSize &&! rs.isAfterLast()){
out.println("<tr><td align=center>" + rs.getString("code") + "</td>");
out.println("<td align=center>" + rs.getString("name") + "</td>");
out.println("<td align=center>" + rs.getString("unit") + "</td>");
out.println("<td align=center>" + df.format(rs.getDouble("tonhand")) + "</td>");
out.println("<td align=center>" + df.format(rs.getDouble("sprice")) + "</td>");
out.println("<td align=center>" + rs.getInt("leadtime") + "</td></tr>");
}
%>
<%
rs.next();
i++; %>
</table>
第<%=intPage%>页 共<%=intRowCount%> 条记录/共<%=intPageCount%>页 <br>
<%if(intPage<2){ %> 首页 | 上一页
<% }else{%> <a href="page.jsp?page=1">首页</a>|<a href="page.jsp?page=<%=intPage-1%>">上一页</a>
<%}%>
<%if((intPageCount-intPage)<1){ %>下一页 | 尾页
<%}else{%>
<a href="page.jsp?page=<%=intPage+1%>">下一页</a> | <a href="page.jsp?page=<%=intPageCount%>">尾页</a>
<%}%> <%
rs.close();
cstmt.close();
conn.close();
}catch (Exception e){
e.printStackTrace();
}
%>
</body>
</html>
<%@ page language = "java" contentType = "text/html;charset=gb2312"%>
<%@ page import = "java.sql.*"%>
<%@ page import = "javax.naming.*"%>
<%@ page import = "javax.sql.DataSource"%>
<%@ page import="java.text.DecimalFormat"%>
<html>
<head>
<LINK href="../css/main.css" type="text/css" rel=stylesheet>
<LINK href="../css/rubbing.css" type="text/css" rel=stylesheet>
<link rel="stylesheet" href="../css/style.css" type="text/css">
</head>
<body background="../images/bg.jpg" >
<%
String strGClass = request.getParameter("GClass");
if (strGClass == null || strGClass == "")
strGClass = "-1";
String iGName = request.getParameter("GName");
if (iGName == null || iGName == "")
iGName = "";
iGName = new String(iGName.getBytes("ISO8859-1"));
String iGCode = request.getParameter("GCode");
if (iGCode == null || iGCode == "")
iGCode = "";
iGCode = new String(iGCode.getBytes("ISO8859-1"));
int iGClass = Integer.parseInt(strGClass);
try{
Context initCtx = new InitialContext();
DataSource ds=null;
ds = (DataSource) initCtx.lookup("java:comp/env/jdbc/webTbd");
Connection conn = ds.getConnection();
CallableStatement cstmt = null;
ResultSet rs = null;
String sql = null;
cstmt = conn.prepareCall("{?=call t_LGoodsPrice(?, ?, ?)}");
cstmt.registerOutParameter(1, java.sql.Types.INTEGER);
cstmt.setInt(2, iGClass);
cstmt.setString(3, iGName);
cstmt.setString(4, iGCode);
rs = cstmt.executeQuery();
/*××××××××××××××××××××××××分页××××××××××××××××××××××*/
int intPageSize; //一页显示的记录数
int intRowCount; //记录总数
int intPageCount; //总页数
int intPage; //待显示页码
String strPage;
int i;
//设置一页显示的记录数
intPageSize=1; //MySelf=Request.ServerVariables("PATH_INFO");
//取得待显示页码
strPage=request.getParameter("page");
if(strPage==null)//表明在QueryString中没有Page这一个参数,此时显示第一页数据
intPage=1;
else{//将字符串转换成整型
intPage=java.lang.Integer.parseInt(strPage);
if(intPage<1) intPage=1;
}
out.println(rs);
//获取记录总数
rs.last();
intRowCount=rs.getRow();
//记算总页数
intPageCount =(intRowCount+intPageSize-1)/intPageSize;
//调整待显示的页码
if(intPage>intPageCount) intPage=intPageCount;
if(intPageCount>0)
//将记录指针定位到待显示页的第一条记录上
rs.absolute((intPage-1)*intPageSize+1);
//显示数据
i=0;
%>
<table border="1" width="100%" align="center" cellspacing="0" cellpadding="0" class="f_sm">
<%
out.println("<tr><td align=center><STRONG>货品编码</STRONG></td>");
out.println("<td align=center><STRONG>货品名称</STRONG></td>");
out.println("<td align=center><STRONG>单位</STRONG></td>");
out.println("<td align=center><STRONG>库存数量</STRONG></td>");
out.println("<td align=center><STRONG>售货价</STRONG></td>");
out.println("<td align=center><STRONG>提前订货期(天)</STRONG></td></tr>");
DecimalFormat df = new DecimalFormat("#0.00");
while(i<intPageSize &&! rs.isAfterLast()){
out.println("<tr><td align=center>" + rs.getString("code") + "</td>");
out.println("<td align=center>" + rs.getString("name") + "</td>");
out.println("<td align=center>" + rs.getString("unit") + "</td>");
out.println("<td align=center>" + df.format(rs.getDouble("tonhand")) + "</td>");
out.println("<td align=center>" + df.format(rs.getDouble("sprice")) + "</td>");
out.println("<td align=center>" + rs.getInt("leadtime") + "</td></tr>");
}
%>
<%
rs.next();
i++; %>
</table>
第<%=intPage%>页 共<%=intRowCount%> 条记录/共<%=intPageCount%>页 <br>
<%if(intPage<2){ %> 首页 | 上一页
<% }else{%> <a href="page.jsp?page=1">首页</a>|<a href="page.jsp?page=<%=intPage-1%>">上一页</a>
<%}%>
<%if((intPageCount-intPage)<1){ %>下一页 | 尾页
<%}else{%>
<a href="page.jsp?page=<%=intPage+1%>">下一页</a> | <a href="page.jsp?page=<%=intPageCount%>">尾页</a>
<%}%> <%
rs.close();
cstmt.close();
conn.close();
}catch (Exception e){
e.printStackTrace();
}
%>
</body>
</html>
解决方案 »
- <s:action executeResult="true"/>当把返回值设置为TRUE进入死循环
- 再问一个关于diplaytag 显示行号的问题
- 页面定时执行判断语句的问题
- 一个难题
- 求由字母a-z,A-Z,数字(0-9),符号(~!@#$%^&*()_<>等)中的至少三种组成的正则表达式
- sql server2005数据库连接不上
- 通过request获取请求地址
- 1.如何取得当前web应用名称? 2.如何取得servlet影射的后缀名
- 用distinct搜索数据库出的一个奇怪问题
- struts2和spring整合出现错误,求大神解答
- jsp基础问题!??
- 请问怎样将取得的二进制数据转换成字符串并显示在页面上?
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.validateScrollable(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.last(Unknown Source)
at org.apache.commons.dbcp.DelegatingResultSet.last(DelegatingResultSet.java:328)
at org.apache.jsp.vpri.result_jsp._jspService(result_jsp.java:129)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unsupported method: ResultSet.last
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.validateScrollable(Unknown Source)
at com.microsoft.jdbc.base.BaseResultSet.last(Unknown Source)
at org.apache.commons.dbcp.DelegatingResultSet.last(DelegatingResultSet.java:328)
at org.apache.jsp.vpri.result_jsp._jspService(result_jsp.java:129)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
prepareCall
public CallableStatement prepareCall(String sql,
int resultSetType,
int resultSetConcurrency)
throws SQLExceptionCreates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. This method is the same as the prepareCall method above, but it allows the default result set type and result set concurrency type to be overridden.
Parameters:
resultSetType - a result set type; see ResultSet.TYPE_XXX
resultSetConcurrency - a concurrency type; see ResultSet.CONCUR_XXX
Returns:
a new CallableStatement object containing the pre-compiled SQL statement
Throws:
SQLException - if a database access error occurs
Since:
1.2
See Also:
What Is in the JDBC 2.0 API