- 浏览: 117198 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (130)
- JUnit4学习 (0)
- Spring3.X学习 (2)
- 日记 (1)
- 文学类 (2)
- Java (15)
- Thingking In Java (11)
- org.apache.poi (4)
- XML (2)
- Log4j (1)
- Jar包收集 (2)
- ExtJs (1)
- 汇编语言 (11)
- 开发工具 (0)
- 电子书 (2)
- Oracle (6)
- Ajax (1)
- Jquery (2)
- myBatis (1)
- Spring2.5学习 (6)
- Tomcat (1)
- MyEclipse (1)
- JSP (1)
- Linux shell 脚本攻略 (7)
- Python3 (2)
- HTML5 (5)
- JavaScript (7)
- Hadoop-1.2.1 (2)
- Python2.7 (12)
- Django (3)
- 软件安装 (1)
- 高级Bash脚本编程指南 (7)
- Linux命令 (3)
- Ansible (2)
- MySQL (2)
- 病历 (1)
- 操作系统 (1)
- CSS (0)
- CSS3 (0)
- 面试题 (1)
最新评论
-
hw1287789687:
http://www.cnblogs.com/hccwu/p/ ...
Java获取真实的IP地址 -
liubey:
String ip = request.getHeader(& ...
Java获取真实的IP地址 -
bewithme:
我记得uploadify这破东西只能在chrome浏览器中才有 ...
Struts2结合Jquery.uploadify上传插件的应用 -
MrLee23:
http://mrlee23.iteye.com/admin/ ...
Struts2结合Jquery.uploadify上传插件的应用 -
crysik:
import com.eshore.ppm.model.com ...
Struts2结合Jquery.uploadify上传插件的应用
2013年10月21日 星期一 21时43分23秒
说明: 继上次的java.sql.SQLException: ORA-01013: user requested cancel of current operation 错误。查了两天也没查出具体原因。后在同事的建议下,延长查询时间。因为生产库不能随意重启,
于是就写了个testQuery.jsp测试页面来测试生产环境中延长脚本查询时间是否可以完全生成文件并导出:
<%@page import="com.poson.cb.lib.DBConn"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFRow"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFRichTextString"%>
<%@page import="java.io.FileOutputStream"%>
<%@page import="java.io.File"%>
<%@page import="java.io.PrintWriter"%>
<%@page import="com.poson.cb.lib.CBConfig2"%>
<%@page import="javax.servlet.jsp.tagext.TryCatchFinally"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.text.SimpleDateFormat"%><META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="0">
<%@ page contentType="text/html; charset=GBK" language="java"%>
<%@ page import="java.util.*" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>移动客户出账全量稽核</title>
<style type="text/css">
.table-b table td
{
border:0px solid #F00;
font-size:smaller
}
.table-c table
{
border-right:1px solid #F00;border-bottom:1px solid #F00
}
.STYLE2 {font-size: 12px}
td
{
font-size: 13px
}
</style>
</head>
<script type="text/javascript">
</script>
<%
System.out.println("页面测试开始......");
String sql1="select count(0) from file_reg_mobile where bil_billing_cycle_id = 201309 and billing_flag = 'S' and file_name like 'LIST%' ";
String sql2=" select p.province_name,m.file_name, t.error_code from tl_error_record_201309 t " +
"left join file_reg_ext_mobile f on t.batch_id = f.serial left join province p " +
"on f.province_use = p.prov_code left join file_reg_mobile m on m.serial = t.batch_id " +
"group by p.province_name,m.file_name, t.error_code";
DBConn con=new DBConn();
Statement statement1=null,statement2=null;
ResultSet set1=null,set2=null;
String filepath="";
int rowCount1=0;
try{
statement1=con.getConn().createStatement();
//延长脚本执行时间
statement1.setQueryTimeout(1000*60*2);
set1= statement1.executeQuery(sql1);
while(set1.next()){
rowCount1=set1.getInt(1);
}
}catch(SQLException e){
System.out.println("脚本1执行错误!"+e);
}finally{
set1.close();
statement1.close();
}
try{
statement2=con.getConn().createStatement();
//设置查询时间
statement2.setQueryTimeout(1000*60*2);
System.out.println("查询开始时间:"+new SimpleDateFormat("yyyy-mm-dd hh24:mm:ss").format(new Date()));
set2= statement2.executeQuery(sql2);
System.out.println("查询结束时间:"+new SimpleDateFormat("yyyy-mm-dd hh24:mm:ss").format(new Date()));
HSSFWorkbook wb=new HSSFWorkbook();
HSSFSheet sheet1=wb.createSheet("测试");
while(set2.next()){
HSSFRow row= sheet1.createRow(sheet1.getLastRowNum()+1);
row.createCell((short)0).setCellValue(new HSSFRichTextString(set2.getString(1)));
row.createCell((short)1).setCellValue(new HSSFRichTextString(set2.getString(2)));
row.createCell((short)2).setCellValue(new HSSFRichTextString(set2.getString(3)));
}
filepath=System.getProperty("user.home")+File.separator+"web"+File.separator+"CB"+File.separator+"test.xls";
FileOutputStream file=new FileOutputStream(new File(filepath));
wb.write(file);
System.out.println("写完Excel时间:"+new SimpleDateFormat("yyyy-mm-dd hh24:mm:ss").format(new Date()));
}catch(SQLException e){
System.out.println("脚本2执行错误!"+e);
}finally{
set2.close();
statement2.close();
}
System.out.println("下载访问路径:"+"http://localhost:7001"+filepath);
%>
<body border="0" bordercolor="#000000" style="border-collapse:collapse;">
<form method="post" name="form1">
<table width="100%" border="1">
<tr>
<td>set1的记录数为:</td>
<td><%= rowCount1%></td>
</tr>
<tr>
<td></td>
<td><a href="<%="http://localhost:7001"+filepath%>">点击下载</a> </td> </tr>
</table>
</form>
</body>
</html>
页面测试开始......
查询开始时间:2013-27-21 1124:27:05
查询结束时间:2013-27-21 1124:27:24
写完Excel时间:2013-27-21 1124:27:24
下载访问路径:http://localhost:7001/CTCB/web/CB/test.xls
测试结果发现:第二个查询结果最长也才用了20s而已。而我登陆生产环境(晚上)测试,完全没问题。问题应该是白天资源忙加上网络速度慢导致无法将生成的文件导出。
==================================================================================================
刚开始界面报如下错误:
<2013-10-21 下午09时41分51秒 GMT+08:00> <Error> <HTTP> <BEA-101017> <[ServletContext(id=1106085697,name=CB,context-path=/CB)] Root cause of ServletException.
java.sql.SQLException: 结果集已耗尽
at weblogic.jdbc.wrapper.ResultSet.getInt(ResultSet.java:278)
at jsp_servlet.__testqery._jspService(__testqery.java:197)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:172)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at com.poson.cb.util.comface.EncodingFilter.doFilter(EncodingFilter.java:164)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7053)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
上面是修改的代码,造成这个错误的原因是出现此错误 是因为,执行的数据库查询没有查询到任何结果,却调用了rs.next() 或者,游标到了查询出来的最后一条记录,又调用了rs.next()则,会找不到next条记录
ResultSet set1=statement.executeQuery(sql1);
ResultSet set2=statement.executeQuery(sql2);
2013-10-22 0:41 记@sanliheludongkou.xichengqu.beijing
恩 这种写法确实是错误的。
说明: 继上次的java.sql.SQLException: ORA-01013: user requested cancel of current operation 错误。查了两天也没查出具体原因。后在同事的建议下,延长查询时间。因为生产库不能随意重启,
于是就写了个testQuery.jsp测试页面来测试生产环境中延长脚本查询时间是否可以完全生成文件并导出:
<%@page import="com.poson.cb.lib.DBConn"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFWorkbook"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFSheet"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFRow"%>
<%@page import="org.apache.poi.hssf.usermodel.HSSFRichTextString"%>
<%@page import="java.io.FileOutputStream"%>
<%@page import="java.io.File"%>
<%@page import="java.io.PrintWriter"%>
<%@page import="com.poson.cb.lib.CBConfig2"%>
<%@page import="javax.servlet.jsp.tagext.TryCatchFinally"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.text.SimpleDateFormat"%><META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="0">
<%@ page contentType="text/html; charset=GBK" language="java"%>
<%@ page import="java.util.*" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>移动客户出账全量稽核</title>
<style type="text/css">
.table-b table td
{
border:0px solid #F00;
font-size:smaller
}
.table-c table
{
border-right:1px solid #F00;border-bottom:1px solid #F00
}
.STYLE2 {font-size: 12px}
td
{
font-size: 13px
}
</style>
</head>
<script type="text/javascript">
</script>
<%
System.out.println("页面测试开始......");
String sql1="select count(0) from file_reg_mobile where bil_billing_cycle_id = 201309 and billing_flag = 'S' and file_name like 'LIST%' ";
String sql2=" select p.province_name,m.file_name, t.error_code from tl_error_record_201309 t " +
"left join file_reg_ext_mobile f on t.batch_id = f.serial left join province p " +
"on f.province_use = p.prov_code left join file_reg_mobile m on m.serial = t.batch_id " +
"group by p.province_name,m.file_name, t.error_code";
DBConn con=new DBConn();
Statement statement1=null,statement2=null;
ResultSet set1=null,set2=null;
String filepath="";
int rowCount1=0;
try{
statement1=con.getConn().createStatement();
//延长脚本执行时间
statement1.setQueryTimeout(1000*60*2);
set1= statement1.executeQuery(sql1);
while(set1.next()){
rowCount1=set1.getInt(1);
}
}catch(SQLException e){
System.out.println("脚本1执行错误!"+e);
}finally{
set1.close();
statement1.close();
}
try{
statement2=con.getConn().createStatement();
//设置查询时间
statement2.setQueryTimeout(1000*60*2);
System.out.println("查询开始时间:"+new SimpleDateFormat("yyyy-mm-dd hh24:mm:ss").format(new Date()));
set2= statement2.executeQuery(sql2);
System.out.println("查询结束时间:"+new SimpleDateFormat("yyyy-mm-dd hh24:mm:ss").format(new Date()));
HSSFWorkbook wb=new HSSFWorkbook();
HSSFSheet sheet1=wb.createSheet("测试");
while(set2.next()){
HSSFRow row= sheet1.createRow(sheet1.getLastRowNum()+1);
row.createCell((short)0).setCellValue(new HSSFRichTextString(set2.getString(1)));
row.createCell((short)1).setCellValue(new HSSFRichTextString(set2.getString(2)));
row.createCell((short)2).setCellValue(new HSSFRichTextString(set2.getString(3)));
}
filepath=System.getProperty("user.home")+File.separator+"web"+File.separator+"CB"+File.separator+"test.xls";
FileOutputStream file=new FileOutputStream(new File(filepath));
wb.write(file);
System.out.println("写完Excel时间:"+new SimpleDateFormat("yyyy-mm-dd hh24:mm:ss").format(new Date()));
}catch(SQLException e){
System.out.println("脚本2执行错误!"+e);
}finally{
set2.close();
statement2.close();
}
System.out.println("下载访问路径:"+"http://localhost:7001"+filepath);
%>
<body border="0" bordercolor="#000000" style="border-collapse:collapse;">
<form method="post" name="form1">
<table width="100%" border="1">
<tr>
<td>set1的记录数为:</td>
<td><%= rowCount1%></td>
</tr>
<tr>
<td></td>
<td><a href="<%="http://localhost:7001"+filepath%>">点击下载</a> </td> </tr>
</table>
</form>
</body>
</html>
页面测试开始......
查询开始时间:2013-27-21 1124:27:05
查询结束时间:2013-27-21 1124:27:24
写完Excel时间:2013-27-21 1124:27:24
下载访问路径:http://localhost:7001/CTCB/web/CB/test.xls
测试结果发现:第二个查询结果最长也才用了20s而已。而我登陆生产环境(晚上)测试,完全没问题。问题应该是白天资源忙加上网络速度慢导致无法将生成的文件导出。
==================================================================================================
刚开始界面报如下错误:
<2013-10-21 下午09时41分51秒 GMT+08:00> <Error> <HTTP> <BEA-101017> <[ServletContext(id=1106085697,name=CB,context-path=/CB)] Root cause of ServletException.
java.sql.SQLException: 结果集已耗尽
at weblogic.jdbc.wrapper.ResultSet.getInt(ResultSet.java:278)
at jsp_servlet.__testqery._jspService(__testqery.java:197)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:172)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at com.poson.cb.util.comface.EncodingFilter.doFilter(EncodingFilter.java:164)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7053)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
上面是修改的代码,造成这个错误的原因是出现此错误 是因为,执行的数据库查询没有查询到任何结果,却调用了rs.next() 或者,游标到了查询出来的最后一条记录,又调用了rs.next()则,会找不到next条记录
ResultSet set1=statement.executeQuery(sql1);
ResultSet set2=statement.executeQuery(sql2);
2013-10-22 0:41 记@sanliheludongkou.xichengqu.beijing
- testQery.rar (1.7 KB)
- 下载次数: 2
评论
2 楼
listen-raining
2013-10-22
须等待 写道
。。。
while(rs.hasNext()) {
rs.next();
}
你那个写法本身就不对
while(rs.hasNext()) {
rs.next();
}
你那个写法本身就不对
恩 这种写法确实是错误的。
1 楼
须等待
2013-10-22
。。。
while(rs.hasNext()) {
rs.next();
}
你那个写法本身就不对
while(rs.hasNext()) {
rs.next();
}
你那个写法本身就不对
发表评论
-
Java RMI远程调用
2015-09-15 19:16 930具体代码: 首先定义 ... -
java.lang.IllegalArgumentException: Illegal group reference
2015-02-01 23:34 500public static void main(String ... -
Java对session的监控
2015-01-12 15:37 1400在Java中可以使用 javax.servlet.http. ... -
Java获取真实的IP地址
2014-12-18 14:58 791// 获取真实IP的方法() public String ... -
Java某个账期月的最大天数
2014-12-18 14:50 900/* * 获取某个账期月的最大天数 * param:s ... -
Java String类型赋值问题
2014-10-23 15:34 1101今天用POI在做Ex ... -
获取类所引用的jar包
2014-09-04 11:35 560System.out.println("HWPFD ... -
批量修改文件名称
2014-09-04 11:13 329package mp3; import java.io.Fi ... -
Java获取系统属性
2013-10-24 11:59 1320package com; public class Vers ... -
Java读取远程主机文件
2013-09-19 00:20 6031//Java利用第三方jar包(ganymed-ssh2-bu ... -
Java时间处理集合
2013-08-27 23:46 821package collections; import ja ... -
ORA-01013: user requested cancel of current operation
2013-08-19 17:01 32502013年8月19日 星期一 16时16分04 ... -
Java 实现一个Null接口
2013-07-02 00:10 579注: 以下代码来自:《Thinking in Java Fo ... -
Java Class.forName()无法加载类
2013-06-26 00:41 16132013年6月26日 星期三 1时01分42秒 packag ...
相关推荐
java.sql.SQLException: 不支持的字符集 (在类路径中添加 orai18n.jar): ZHS16GBK ……
在oracle里面运行一下,解决Exception java.sql.SQLException ORA-00600 内部错误代码
服务器出现java.sql.SQLException No suitable driver found for 的
NULL 博文链接:https://zhang-zling.iteye.com/blog/980488
本文主要介绍了关于MySQL存储表情报错:java.sql.SQLException: Incorrect string value: ‘\xF0\x9F\x92\xA9\x0D\x0A…’的相关解决方法,分享出供大家参考学习,下面话不多说了,来一起看看详细的介绍: ...
oracle ora-各种常见java.sql.SQLException归纳
java.sql.SQLException: null, message from server: “Host ‘223.72.41.7’ is not allowed to connect to this MySQL server” 客户端访问时报错: 解决方法: 1,登陆服务器 mysql> use mysql; //用mysql ...
Q: I am working with ... I am using updateBinaryStream method of resultset to update the BLOB field but it is failing after giving following exception java.sql.SQLException: Internal Error: Unable to
主要给大家介绍了关于MySQL存储表情时报错:java.sql.SQLException: Incorrect string value: 'xF0x9Fx92xA9x0Dx0A...'的解决方法,文中通过示例代码介绍的非常详细,需要的朋友可以参考借鉴,下面来一起看看吧。
mysql5.6连接驱动jaf,可处理报错java.sql.SQLException: No suitable driver
java.sql.SQLException: Operation not allowed after ResultSet closed java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in
异常错误:java.sql.SQLException: The server time zone value ‘?й???’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTime...
oracle 10g 数据库驱动下载:oracle jdbc dirver
异常详细信息: System.Data.SqlClient.SqlException: 已成功与服务器建立连接,但是在登录过程中发生错误。 (provider: 共享内存提供程序, error: 0 - 管道的另一端上无任何进程。) 源错误: 行 35: } 行 36: if (con...
问题是这样的…我在VS2008直接运行打开网页,可以连接... 异常详细信息: System.Data.SqlClient.SqlException: 无法打开登录所请求的数据库 “TakeClass”。登录失败。 用户 ‘2D2727E2578F446\ASPNET’ 登录失败。
绝对好用的9i驱动包+10g驱动包 解决java.sql.SQLException: 不支持的特性 解决oracle.jdbc.driver.OracleDatabaseMetaData.supportsGetGeneratedKeys()Z异常 等等
Caused by: java.sql.SQLException: java.lang.ClassNotFoundException: org.apache.hive.jdbc.HiveDriver at com.trs.gateway.commons.hive.HiveFeature.getConnection(HiveFeature.java:57) at ...
import java.sql.SQLException; import java.sql.Statement; import java.sql.ResultSet; /** * @author Administrator * */ public class sqlServer { String DBDriver=...