java.sql.SQLException: Before start of result set
2008-08-16 11:39
731 查看
javaWeb项目中需要一个实时提醒的功能,也就是某人做了某一操作,可以立即提醒到当前在线的用户
最开始想在用户做了操作后,储存一个状态到数据库中然后用每隔几秒用ajax去请求后台查询数据库来确定是否显示提醒窗口
提醒窗口使用jquery easyui 的messager 在右下角弹出如下图
后查得可通过AJAX长轮询的方法来解决频繁对后台的请求,进一步减小压力
在实现过程发现AJAX的多次请求会出现多线程并发的问题又使用线程同步来解决该问题
个人对ajax长轮询的一点愚见
ajax请示后台时,后台程序并没有立即返回信息而是挂起,当符合条件时才会返回信息
文笔不好,只能白话出来,如有不对的地方还请各位指正,一起探讨学习!
现贴出部分代码
js ajax实现部分
使用 jquery easyui的messager弹出提示窗口代码
后台Action
最开始想在用户做了操作后,储存一个状态到数据库中然后用每隔几秒用ajax去请求后台查询数据库来确定是否显示提醒窗口
提醒窗口使用jquery easyui 的messager 在右下角弹出如下图
后查得可通过AJAX长轮询的方法来解决频繁对后台的请求,进一步减小压力
在实现过程发现AJAX的多次请求会出现多线程并发的问题又使用线程同步来解决该问题
个人对ajax长轮询的一点愚见
ajax请示后台时,后台程序并没有立即返回信息而是挂起,当符合条件时才会返回信息
文笔不好,只能白话出来,如有不对的地方还请各位指正,一起探讨学习!
现贴出部分代码
js ajax实现部分
function getRtmMsg(show){ $.ajax({ type:"POST", url:"rtmAction!getMsg.action", data:"show="+show, success: function(msg){ if(msg!=null){ bottomRight(); getRtmMsg("0"); } } }); }
使用 jquery easyui的messager弹出提示窗口代码
function bottomRight(){ $.messager.show({ title:'提醒', msg:'下载考生', showType:'show' }); }
后台Action
/** * 实时消息Action * @author wangwei * May 23, 2013 */ public class RtmAction extends ActionSupport{ HttpServletResponse response = ServletActionContext.getResponse(); HttpServletRequest request = ServletActionContext.getRequest(); private static final ThreadLocal threadLocal = new ThreadLocal(); private static Object lock = new Object(); public void getMsg(){ String show = request.getParameter("show"); if("0".equals(show)){ RtmTemplate.cjzxShow = false; } try { //多线程同步解决并发问题 synchronized(lock){ while(!RtmTemplate.cjzxShow){ System.out.println("检测中。。。。"); Thread.sleep(5000); } } response.getWriter().println("1"); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } }
相关文章推荐
- java.sql.SQLException: Before start of result set解决方法
- Java.sql.SQLException: Before start of result set
- Java与mysql数据库编程中遇见“Before start of result set at com.mysql.jdbc.SQLError.createSQLException” 的解决办法
- java.sql.SQLException: Before start of result set
- Java与mysql数据库编程中遇见“Before start of result set at com.mysql.jdbc.SQLError.createSQLException” 的解决办法
- Java与mysql数据库编程中遇见“Before start of result set at com.mysql.jdbc.SQLError.createSQLException” 的解决办法
- java.sql.SQLException: Before start of result set
- java.sql.SQLException: Before start of result set
- java.sql.SQLException: Before start of result set
- 解决 java.sql.SQLException: Before start of result set
- java.sql.SQLException: Before start of result set(转)
- java.sql.SQLException: Before start of result set的原因
- java.sql.SQLException: Before start of result set
- java.sql.SQLException: Before start of result set错误
- java.sql.SQLException: Before start of result set
- java.sql.SQLException: Before start of result set
- java.sql.SQLException: Before start of result set
- java从MySQL表中取出数据时报错:java.sql.SQLException: Before start of result set
- java.sql.SQLException:Before start of result set解决方法
- java.sql.SQLException: Before start of result set解决方法