TimerTask 定时器类问题...抛java.lang.NullPointerException异常 [问题点数:40分,结帖人lin_cz]

Bbs1
本版专家分:20
结帖率 73.33%
Bbs9
本版专家分:68052
Blank
GitHub 绑定GitHub第三方账户获取
Blank
红花 2011年6月 Java大版内专家分月排行榜第一
Blank
黄花 2019年3月 Java大版内专家分月排行榜第二
Blank
蓝花 2019年7月 其他开发语言大版内专家分月排行榜第三
2018年11月 Java大版内专家分月排行榜第三
2012年7月 Java大版内专家分月排行榜第三
2011年11月 Java大版内专家分月排行榜第三
2007年12月 Java大版内专家分月排行榜第三
2007年10月 Java大版内专家分月排行榜第三
Bbs1
本版专家分:20
Bbs5
本版专家分:4945
Bbs1
本版专家分:20
TimerTask抛不出运行时异常
用J2SE和Android,都运行相同的TimerTask,表现 1. Java代码 import java.util.Timer; import java.util.TimerTask; public class ddd { public static void main(String[] args) throws Exception { Timer ...
关于定时器和TimerTask的问题
现在有个<em>问题</em>是这样的:我要用一个<em>定时器</em>来每隔一段时间执行一个方法。但是因为某些原因,除了继承TimerTask类,用timer.schedule方法实现,还有其他办法吗?
关于java.lang.NullPointerException异常问题!
我在ORACLE表中设置了一个CLOB字段,然后在插入字段内容时,先插入一个空的字段,然后查询出这个字段,再写入内容,写入内容的代码如下:rn1 oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob(1);rn2 java.io.Writer clobWriter = clob.getCharacterOutputStream();rn3 clobWriter.write(strComment);rn4 clobWriter.flush();rn5 clobWriter.close();rn<em>问题</em>来了,在第二句时,由于我们得到的clob字段是前面插入的空字段,所以clob变量内容为空,接着,把clob变量的getCharacterOutputStream()方法的结果赋值给clobWriter变量时,会发生java.lang.NullPointerException.rn其实这个结果不会影响结果,程序仍然能够正常执行, 内容也能顺利提交.rn但我的页面总不能提交成功后让别人看不懂吧?rn再说,这个<em>异常</em>也是块心病,有了他就不太完美了。 rn问问有啥好办法解决没?
java.lang.NullPointerException异常
rnrn rn rn rnrn rnrnrnrn rn rn rn 新闻类别信息修改rn rn rn rn rn rn rn rn rn 新闻标题: rn rn rn rn rn 新闻类型:rn rn rn rn rn 添加时间:rn rn rn rn 针对省份:rn rn rn rn rn 添加作者:rn rn rn rn 新闻内容:rn rn rn rn rn rn rnrn rn rnrn rn rn rnrnrn上面是我的JSP页面代码rn00rn3rn4rnselect * from tb_pro where P_id='4'rnjava.lang.NullPointerExceptionrn这是在控制台输出的结果rn在传一个值过来后,能接到,也能执行SQL查询,但是一到rs(N_sign=rs.getString("P_name");)那里就走不下去了rn哪位高手知道错误原因啊,帮帮忙!谢谢了!
java.lang.NullPointerException 异常
<em>问题</em>描述:[#list User as user]这种对象的遍历我会,就是不知道[#list page.content as xxx]的page是分页的意思吗??controller层应该怎样去寻找相应的对象啊???rnrn请求页面的时候报的这个<em>异常</em>:rnjava.lang.NullPointerExceptionrn at com.duoduo.service.impl.BaseServiceImpl.findPage(BaseServiceImpl.java:84)rnrn页面源码:rn[#list page.content as delStorageInventoryIn]rn rn $delStorageInventory.upcrn rn rn $delStorageInventory.snrn rn rn $delStorageInventory.quantityrn rn[/#list]rnrncontroller层:rn@RequestMapping(value="/list",method=RequestMethod.GET)rnpublic String list(Pageable pageable, ModelMap model) rn List filters = new ArrayList();rn Filter filter = new Filter();rn filter.setProperty("delStorage");rn filter.setOperator(com.duoduo.Filter.Operator.in);rn filter.setValue(this.adminService.getCurrent().getDelStorages());rn filters.add(filter);rn pageable.setFilters(filters);rn model.addAttribute("page", delStorageInventoryInService.findPage(pageable));rn return "/admin/del_storage_inventory_in/list";rnrnrnrn
异常 java.lang.NullPointerException ??
public Class Arn public A()rn rn public A[] getA()rn return a;rn rn rn public void setA()rn int i = 0;rn tryrn while((i++);rn rn catch(Exception e)rn rnrn private A[] a= new A[20];rn public int j; rn public String c;rnrnrn//在B中调用ArnPublic Class Brn public static void main(String[] args)rn A a= new A();rn a.setA();rn rnrnrn
C# 抛异常问题
using System;rnrnnamespace ConsoleApplication2rnrn class DBHelperrn rn public void showerr()rn rn tryrn rn Convert.ToInt32("33");rn rn catch (Exception)rn rn Console.WriteLine("<em>异常</em>");rn return;rn rn rn rnrn class Programrn rn static void Main(string[] args)rn rn DBHelper dbHelper=new DBHelper();rn dbHelper.showerr();rn Console.WriteLine("执行成功!");rnrn rn rnrnrn以上代码如何让其类实例抛出<em>异常</em>时,Console.WriteLine("执行成功!");不执行?rn除了把trycatch放外面...
Android中使用定时器TimerTask类介绍
在Android平台中需要反复按周期执行方法可以使用Java上自带的TimerTask类,TimerTask相对于Thread来说对于资源消耗的更低,除了使用Android自带的AlarmManager使用Timer<em>定时器</em>是一种更好的解决方法。 我们需要引入import java.util.Timer; 和 import java.util.TimerTask; private Timer...
dbgride抛异常问题
dbgride拖动最后一列直到列宽比dbgride本身还宽的时候,就会提示“Grid index out of range”,可以不让它弹出来吗?
线程抛异常问题
先看代码:rnpublic class ThreadSleep implements Runnable rn Random rs = new Random();rn int i = rs.nextInt() % 9 + 1;rnrn public void run() rn System.out.println("线程开始:");rn try rn Thread.sleep(i * 1000);rn catch (InterruptedException e) rn e.printStackTrace();rn rn System.out.println("休眠了" + i + "秒钟");rn rnrnrn启动这个线程.60%会抛出如下<em>异常</em>:rn线程开始:rnException in thread "pool-1-thread-1" java.lang.IllegalArgumentException: timeout value is negativern at java.lang.Thread.sleep(Native Method)rn at cai.zhi.huan.ThreadSleep.run(ThreadSleep.java:12)rn at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)rn at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)rn at java.lang.Thread.run(Unknown Source)rn但还有40%会正常运行:rn线程开始:rn休眠了1秒钟rn请问.正常吗.?rn如果用循环同时启动10次.那么99.9%会抛出<em>异常</em>.如果正常..那线程还有什么用?....
定时器Timer、TimerTask时间任务类
package com.tender.news.crawler; import java.util.Date; import java.util.Timer; import java.util.TimerTask; public class TimerThread { public static void main(String[] args) { Timer timer = new
Timer和TimerTask定时器使用
Timer是一种<em>定时器</em>工具,用来在一个后台线程计划执行指定任务。它可以计划执行一个任务一次或反复多次。 TimerTask一个抽象类,它的子类代表一个可以被Timer计划的任务。具体的任务在TimerTask中run接口中实现。 通过Timer中的schedule方法启动定时任务。 一、运行<em>定时器</em> 启动一个<em>定时器</em>实质是启动一个线程 1、在指定日期运行<em>定时器</em>任务,只运行一次 ...
spring + jdk TimerTask定时器
spring + jdk TimerTask<em>定时器</em> 完整可运行
定时器TimerTask入门Demo
package cn.itcast.web.gui; import java.util.Calendar; import java.util.Date; import java.util.Timer; import java.util.TimerTask; public class Demo2 { public static void main(String[] args) { Tim
timerTask任务定时器
简单的一个<em>定时器</em>,异步任务 Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { loadMainUI(); } ...
定时器任务 TimerTask(Spring)
1. 继承 TimerTask 类 public class GhDoctorStoppedTimeTask extends TimerTask  2.在run(){} 方法里执行 public void run() { int num = 0; int numstop = 0; try { // 扫描省中医停诊 numstop = GhCheckSchedule
详解TimerTask定时器任务
一、概述 TimerTask类的全名为java.util.TimerTask,直接继承了java.lang.Object类,并且实现了java.lang.Runnable接口。TimerTask是一种可以由<em>定时器</em>调度为执行一次或重复执行的任务。 二、构造器 1. TimerTask() 创建一个新的<em>定时器</em>任务。 三、方法 1. boo
JDK工具类_____TimerTask定时器
import java.util.Date; import java.util.Timer; import java.util.TimerTask; /** * @author God jdk自带的任务器 */ public class TimerTest extends TimerTask { @Override public void run() { System.out.pri
java 自定义定时器(TimerTask)
需求:实现一个简单的定时任务  Version:1   /** * 这是一个简单的定时任务类 */ public class Timing extends TimerTask{ @Test public static void main(String[] args) { Timing timing = new Timing(); T...
Android 定时器TimerTask 简单使用
Android平台中需要反复按周期执行方法可以使用Java上自带的TimerTask类,TimerTask相对于Thread来说对于资源 消耗的更低,除了使用Android自带的AlarmManager使用Timer<em>定时器</em>是一种更好的解决方法。 我们需要引入 import java.util.Timer; 和 import java.util.TimerTask; priva
Timer和TimerTask 定时器和定时任务
这两个类使用起来非常方便,可以完成我们对<em>定时器</em>的绝大多数需求Timer类是用来执行任务的类,它接受一个TimerTask做参数 Timer有两种执行任务的模式,最常用的是schedule,它可以以两种方式执行任务:1:在某个时间(Data),2:在某个固定的时间之后(int delay).这两种方式都可以指定任务执行的频率 java.util.Timer<em>定时器</em>,实际上是个线程,定时调...
异常
抛<em>异常</em> 引题: 例2 比如电商公司发快递,路上出现突发的龙卷风,然后快递上天了找不到,最后客户投诉。客服人员将这个之前从未有过的状况报告公司。 例4 公司里出现一个<em>问题</em>,基层员工没有权利决定,他就叫来了部门经理,部门经理也没有解决,就上报更上一级的领导。 例5 一个代码项目比较大,几十个模块但比较相似,如果用户表单输入错误 需要补货<em>异常</em>打印信息。但每个模块都写提示信息的话重复累。可以抛<em>异常</em>给上层函...
异常了!
'System.Data.ConstraintException' のハンドルされていない例外が system.data.dll で発生しました。rnrn追加情報 : 列 'TmpRASex' は一意であるように制約されています。値 '男' は既に存在しますrnrn怎么解决这个<em>问题</em>呢?
定时器任务 TimerTask
package ZHANG.API; import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Timer; import java.util.TimerTask; public class TestCale
定时器Timer以及TimerTask
Timer TimerTask
定时器之Timer和TimerTask深入分析
【创建时间】2016/8/31 schedule:下一次的执行时间点=上一次程序执行完成的时间点+间隔时间 scheduleAtFixedRate:下一次的执行时间点=上一次程序开始执行的时间点+间隔时间 ;并且因为前一个任务要执行6秒,而当前任务已经开始执行了,因此两个任务间存在重叠,需要考虑线程同步 timer要注意的<em>问题</em>: 每一个Timer仅对应唯一一个线程。 Timer不保证任务
Java多线程基础(二)定时器类:Timer类和TimerTask类
Java多线程基础(二)<em>定时器</em>类:Timer类和TimerTask类Timer类和TimerTask类是jdk实现<em>定时器</em>功能的早期方法,jdk1.5以前就支持Timer类和TimerTask类。JDK1.5之后引入了新的机制,将在后续博文中研究。1 指定时间间隔后执行任务import java.util.Date; import java.util.Timer; import java.util.T
一个构造函数抛异常问题
[code=C/C++]class Arnrnint key;rnA(int n):key(n)rn rn init();rn rnvoid init()rn rn //some codern throw AException();rn rn;rnrnA* a = NULL;rna = new A(3);[/code]rnrn在init的时候抛出<em>异常</em>来,A被析构掉,但此时a已经不是NULL了。
optimize 运行时抛异常问题
jbuilderX,在debug模式下能跑出页面,但是在optimize下跑就抛<em>异常</em>,servlet错误,好像跟jsp中的一段从bean里取出数据显示在页面上的代码有关,把那段注释掉就可以跑出画面了。rn 哪位高手遇到过类似<em>问题</em>吗?不吝赐教啊,多谢了!
数据抛异常类的用法(exception)
因为数据库有<em>异常</em>的数据增删改查都会造成数据库挂掉 后端就没有返回请求,造成前端一直在等待结果 为了避免这种情况 所以在数据进行处理,先前端筛选,后端筛选(防止不经前端暴力数据注入) <em>异常</em>类的抛出不许要带返回请求,因为本身就是个返回值!!! Exception 类及其子类是 Throwable 的一种形式,它指出了合理的应用程序想要捕获的条件。 构造方法 Exception(String mess...
Timer和TimerTask线程定时器用法
Timer和TimerTask线程<em>定时器</em>用法// 线程Timer Timer timer = new Timer(); timer.schedule(new TimerTask() {//要执行的任务 @Override public void run() { System.out.println("复习java基础"); } }, 1000, //执行的时间
j2me-定时器(timertask)使用及初探
首先,说下<em>定时器</em>的基本使用,以下内容摘自nokia 论坛里的一篇文章:  《为60系列平台设计java应用》--<em>定时器</em>    各种<em>定时器</em>让各种应用能方便地规划任务,而不必对线程进行调配。使用线程通常需要更为复杂的设计,并需要更多的系统资源,对各种小设备而言,比较奢侈。  创建一个<em>定时器</em>的范例:   public class m
J2ME-定时器(TimerTask)使用及初探
作者:zxhwolfe 文章来源:http://www.j2medev.com/Article/ShowArticle.asp?ArticleID=899 最近完成个J2ME游戏,一直以来总想写点东西给大家~因为以前总是在索取,现在把J2ME的入门知识-<em>定时器</em>的相关知识以及我的一点体会-付出给大家,内容不多只是它的使用,希望对入门的J2ME开发者有所帮助。 首先,说下<em>定时器</em>的基本使用,以下内容...
java.lang.NullPointerException异常处理问题
public static String []split (String s1,String s2)StringBuilder[]sp = new StringBuilder[s1.length ()];rnint number = 0;rnfor(int i=0;i < s1.length ();i++)rn for(int j =0;j < s2.length ();j ++)rn if (s1. charAt(i) !=s2.charAt(j):rn rn sp[number ].append (s1. charAt(i) );//报错行rn else rn sp[number++ ].append ( s1. charAt(i));rn number++ ;rnrnrnnumber ++;rnString []spr = new String [number ];rnfor(int i=0;i < number; i++)rn spr [i] = sp. toString ();rnrnreturn spr; rn
java.lang.NullPointerException是什么异常?
我在做jsp程序的时候出现了java.lang.NullPointerExceptionrn<em>异常</em>,不知道如何排除,望指教.
Spring java.lang.NullPointerException异常~
[color=#FF0000]Spring 配置文件[/color]rn[code=Java]rn rnrnrn rn rn com.microsoft.sqlserver.jdbc.SQLServerDriverrn rn rn rn jdbc:sqlserver://localhost:1433;databaseName=edaiyanrn rn rn rn sarn rn rn Xwin1989rn rn rn rn rn rn rn rn rn rn rn rn rn org.hibernate.dialect.SQLServerDialectrn truern falsern rn rn rn rn rn rn com.xwin.entity.Messagesrn com.xwin.entity.MessageStatusrn rn rn rn rn rn rn rn rn rnrn[/code]rnrnrnrn[color=#FF0000]Class Messages[/color]rnrn[code=Java]rnpackage com.xwin.dao;rnimport java.util.List;rnimport com.xwin.entity.Messages;rnpublic interface MessageDAO rn rn public Messages get(int messageId);rn public void add(Messages message);rn public void del(Messages messageId);rn public void update(Messages message);rn public List search(final Messages condition);rnrnrn[/code]rnrn[color=#FF0000]Class MessageDAOImpl[/color]rnrn[code=Java]rnrnpackage com.xwin.dao.hibimpl;rnimport java.sql.SQLException;rnimport java.util.List;rnrnimport com.xwin.dao.MessageDAO;rnimport com.xwin.entity.Messages;rnrnimport org.hibernate.Criteria;rnimport org.hibernate.HibernateException;rnimport org.hibernate.Session;rnimport org.hibernate.criterion.MatchMode;rnimport org.hibernate.criterion.Order;rnimport org.hibernate.criterion.Restrictions;rnrnimport org.springframework.orm.hibernate3.HibernateCallback;rnimport org.springframework.orm.hibernate3.HibernateTemplate;rnimport org.springframework.orm.hibernate3.support.HibernateDaoSupport;rnpublic class MessageDAOImpl extends HibernateDaoSupport implements MessageDAOrnrn @Overridern public Messages get(int messageId) rn // TODO Auto-generated method stubrn System.out.print(messageId); rn return (Messages)super.getHibernateTemplate().get(Messages.class, messageId);rn rnrn @Overridern public void add(Messages message) rn // TODO Auto-generated method stubrn super.getHibernateTemplate().save(message);rn rnrn @Overridern public void del(Messages message) rn // TODO Auto-generated method stubrn super.getHibernateTemplate().delete(message);rn rnrn @Overridern public void update(Messages message) rn // TODO Auto-generated method stubrn super.getHibernateTemplate().update(message);rn rn rnrn @Overridern public List search(final Messages condition) rn // TODO Auto-generated method stubrn return super.getHibernateTemplate().executeFind(new HibernateCallback() rnrn @Overridern public Object doInHibernate(Session session)rn throws HibernateException, SQLException rn // TODO Auto-generated method stubrn Criteria c = session.createCriteria(Messages.class);rn if(null != condition)rn rn rn rn c.addOrder(Order.asc("messno"));rn return c.list();rn rn rn );rn rn rn /**rn * 查rn * @param hql hql语句rn * @returnrn */rn public List list(String hql) rn List ret = null;rn ret = super.getHibernateTemplate().find(hql);rn return ret;rn rn rnrnrnrn[/code]rnrnrn[code=Java]rnpackage com.xwin.entity;rnrnimport java.sql.Timestamp;rnrnimport javax.persistence.CascadeType;rnimport javax.persistence.Column;rnimport javax.persistence.Entity;rnimport javax.persistence.GeneratedValue;rnimport javax.persistence.GenerationType;rnimport javax.persistence.Id;rnimport javax.persistence.JoinColumn;rnimport javax.persistence.ManyToOne;rnimport javax.persistence.Table;rnrn/**rn * Messages entity. @author MyEclipse Persistence Toolsrn */rn@Entityrn@Table(name="messages")rnpublic class Messages implements java.io.Serializable rnrn // Fieldsrnrn private Integer id; rn private MessageStatus messageStatus; rn private String message; rn private Timestamp date;rnrn // Constructorsrnrn /** default constructor */rn public Messages() rn rnrn /** minimal constructor */rn public Messages(Integer id, MessageStatus messageStatus, String message) rn this.id = id;rn this.messageStatus = messageStatus;rn this.message = message;rn rnrn /** full constructor */rn public Messages(Integer id, MessageStatus messageStatus, String message,rn Timestamp date) rn this.id = id;rn this.messageStatus = messageStatus;rn this.message = message;rn this.date = date;rn rnrn // Property accessorsrnrn @Idrn @GeneratedValue(strategy = GenerationType.IDENTITY)rn public Integer getId() rn return this.id;rn rnrn public void setId(Integer id) rn this.id = id;rn rnrn @ManyToOne(cascade = CascadeType.PERSIST,CascadeType.MERGE)rn @JoinColumn(name="messageStatusId")rn public MessageStatus getMessageStatus() rn return this.messageStatus;rn rnrn public void setMessageStatus(MessageStatus messageStatus) rn this.messageStatus = messageStatus;rn rnrn @Column(name="message")rn public String getMessage() rn return this.message;rn rnrn public void setMessage(String message) rn this.message = message;rn rnrn @Column(name="date")rn public Timestamp getDate() rn return this.date;rn rnrn public void setDate(Timestamp date) rn this.date = date;rn rnrnrn[/code]rnrn[code=Java]rnpackage com.xwin.entity;rnrnimport java.util.HashSet;rnimport java.util.Set;rnrnrnimport javax.persistence.CascadeType;rnimport javax.persistence.Column;rnimport javax.persistence.Entity;rnimport javax.persistence.GeneratedValue;rnimport javax.persistence.GenerationType;rnimport javax.persistence.Id;rnimport javax.persistence.JoinColumn;rnimport javax.persistence.OneToMany;rnimport javax.persistence.OrderBy;rnimport javax.persistence.Table;rnrnimport org.hibernate.annotations.Fetch;rnimport org.hibernate.annotations.FetchMode;rnrn/**rn * MessageStatus entity. @author MyEclipse Persistence Toolsrn */rn@Entityrn@Table(name="messageStatus")rnpublic class MessageStatus implements java.io.Serializable rnrn // Fieldsrnrn rn private Integer id;rn rn rn private String status;rn rn rn private Set messageses = new HashSet(0);rnrn // Constructorsrnrn /** default constructor */rn public MessageStatus() rn rnrn /** minimal constructor */rn public MessageStatus(Integer id, String status) rn this.id = id;rn this.status = status;rn rnrn /** full constructor */rn public MessageStatus(Integer id, String status, Set messageses) rn this.id = id;rn this.status = status;rn this.messageses = messageses;rn rnrn // Property accessorsrnrn @Idrn @GeneratedValue(strategy =GenerationType.IDENTITY )rn @Column(name="id")rn public Integer getId() rn return this.id;rn rnrn public void setId(Integer id) rn this.id = id;rn rnrn @Column(name="status",length=50)rn public String getStatus() rn return this.status;rn rnrn public void setStatus(String status) rn this.status = status;rn rnrn @OneToMany(cascade=CascadeType.ALL,mappedBy="messageStatus")rn @JoinColumn(name="messageStatusId")rn @Fetch(FetchMode.SUBSELECT)rn @OrderBy("id")rn public Set getMessageses() rn return this.messageses;rn rnrn public void setMessageses(Set messageses) rn this.messageses = messageses;rn rnrnrn[/code]rnrnrnrn[color=#FF0000][b]测试类[/b][/color]rn[code=Java]rnpackage com.xwin.test;rnrnimport com.xwin.entity.Messages;rnimport com.xwin.dao.MessageDAO;rnrnimport com.xwin.dao.hibimpl.MessageDAOImpl;rnpublic class test rnrn /**rn * @param argsrn */rn public static void main(String[] args) rn // TODO Auto-generated method stubrn MessageDAO md = new MessageDAOImpl();rn Messages tm = md.get(1);rn System.out.println("--------SYSTEM----------");rn System.out.println(tm.getId() + " " + tm.getMessage());rn System.out.println(tm.getMessageStatus().getStatus() + " " + tm.getDate());rn rnrnrnrn[/code]
异常来袭!!! java.lang.NullPointerException!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12-03 11:15:53.327: ERROR/AndroidRuntime(1018): FATAL EXCEPTION: mainrn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): java.lang.NullPointerExceptionrn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:398)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.ArrayAdapter.getDropDownView(ArrayAdapter.java:419)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.Spinner$DropDownAdapter.getDropDownView(Spinner.java:543)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.Spinner$DropDownAdapter.getView(Spinner.java:539)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.AbsListView.obtainView(AbsListView.java:1949)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.ListView.measureHeightOfChildren(ListView.java:1228)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.ListView.onMeasure(ListView.java:1139)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.view.View.measure(View.java:10828)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4351)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1284)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.LinearLayout.measureVertical(LinearLayout.java:613)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.LinearLayout.onMeasure(LinearLayout.java:519)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.view.View.measure(View.java:10828)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4351)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1284)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.LinearLayout.measureVertical(LinearLayout.java:613)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.LinearLayout.onMeasure(LinearLayout.java:519)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.view.View.measure(View.java:10828)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4351)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.FrameLayout.onMeasure(FrameLayout.java:267)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.view.View.measure(View.java:10828)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4351)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1284)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.LinearLayout.measureVertical(LinearLayout.java:613)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.LinearLayout.onMeasure(LinearLayout.java:519)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.view.View.measure(View.java:10828)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4351)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.widget.FrameLayout.onMeasure(FrameLayout.java:267)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:1889)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.view.View.measure(View.java:10828)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.view.ViewRoot.performTraversals(ViewRoot.java:913)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.view.ViewRoot.handleMessage(ViewRoot.java:2040)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.os.Handler.dispatchMessage(Handler.java:99)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.os.Looper.loop(Looper.java:132)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at android.app.ActivityThread.main(ActivityThread.java:4123)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at java.lang.reflect.Method.invokeNative(Native Method)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at java.lang.reflect.Method.invoke(Method.java:491)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)rn12-03 11:15:53.327: ERROR/AndroidRuntime(1018): at dalvik.system.NativeStart.main(Native Method)rn
异常">出现" java.lang.NullPointerException " 异常
出现" java.lang.NullPointerException " <em>异常</em>:rn出现<em>异常</em>的函数:rn//将获取来的车次列表中的站点号换成站点名rnpublic static Vector stationNo2stationName(conn_Bus db,Vector cheCiList) throws Exceptionrn Vector result=null; rn businfo bus=new businfo();rn String startStationName=null,endStationName=null;rn rn for(int i=0;i
异常java.lang.NullPointerException是什么原因
<em>异常</em>java.lang.NullPointerException是什么原因
JSF抛出java.lang.NullPointerException异常
最近看了JSF感觉不错,我自己的机子只装了Tomcat5rn在Tomcat5下跑起来没有<em>问题</em>,所以我在项目里也采用了JSFrn现在要移植到websphere5下去,怎么也不成功!rn出现下面错误:rn[05-6-13 13:24:54:969 CST] 5176e99f WebGroup E SRVE0026E: [Servlet 错误]-[Faces Servlet]:java.lang.NullPointerExceptionrn at javax.faces.webapp.FacesServlet.init(FacesServlet.java:144)rn at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doInit(StrictServletInstance.java:82)rn at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._init(StrictLifecycleServlet.java:147)rn at com.ibm.ws.webcontainer.servlet.PreInitializedServletState.init(StrictLifecycleServlet.java:270)rn at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.init(StrictLifecycleServlet.java:113)rn at com.ibm.ws.webcontainer.servlet.ServletInstance.init(ServletInstance.java:175)rn at javax.servlet.GenericServlet.init(GenericServlet.java:258)rn at com.ibm.ws.webcontainer.webapp.WebAppServletManager.addServlet(WebAppServletManager.java:761)rn at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadServlet(WebAppServletManager.java:257)rn at com.ibm.ws.webcontainer.webapp.WebAppServletManager.getServletReference(WebAppServletManager.java:382)rn at com.ibm.ws.webcontainer.webapp.WebApp.getServletReference(WebApp.java:589)rn at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcherInfo.calculateInfo(WebAppRequestDispatcherInfo.java:177)rn at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcherInfo.(WebAppRequestDispatcherInfo.java:59)rn at com.ibm.ws.webcontainer.webapp.WebApp.getRequestDispatcher(WebApp.java:1415)rn at com.ibm.ws.webcontainer.webapp.WebApp.getRequestDispatcher(WebApp.java:1376)rn at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:196)rn at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)rn at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)rn at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:331)rn at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)rn at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:432)rn at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:343)rn at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))rnrn到网上找了好多资料说在web.xml中加侦听器:rn rn com.sun.faces.config.ConfigureListenerrn rn结果还是一样的错误!!rn
Java 工具类 —— 定时器(Timer/TimerTask)
import java.util.Timer; import java.util.TimerTask; public class Timer { .... public void schedule(TimerTask task, long delay) { .... } .... } public abstrac...
传统定时器技术 Timer and TimerTask
本文为张孝祥java并发课程的学习笔记。 java.util.Timer<em>定时器</em>,实际上是个线程,定时调度所拥有的TimerTasks。 一个TimerTask实际上就是一个拥有run方法的类,需要定时执行的代码放到run方法体内,TimerTask一般是以匿名类的方式创建。 我们看看看Timer的api文档 它拥有以下的几个方法 cancel,取消任务 purge,移除已经取消的
定时器实现方式之TimerTask、Timer
在未来某个指定的时间点或者经过一段时间延迟后执行某个事件,这时候就需要用到<em>定时器</em>了。<em>定时器</em>的实现方式有很多种,今天总结最简单的实现方式。java 1.3引入了<em>定时器</em>框架,用于在<em>定时器</em>上下文中控制线程的执行,其由类Timer和TimerTask构成。Timer适用于大规模并发调度定时任务,在内部,该类使用二进制的堆表示其定时任务队列。 通过继承TimerTask或者创建匿名类的方式重写run()方...
Timer定时器、TimerTask、Random随机数
public class TimerAndTimerTask { private static Timer timer; private static TimerTask task;//TimerTask是抽象类implements Runnable /** * 测试Timer和TimerTask */ public static void main(String[] args)
定时器TimerTask:定时清理上传文件
import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.util.Timer; import java.util.TimerTask; import org.apache.commons.
使用Handler和Timertask实现定时器
用Handler和Timertask实现一个简单的<em>定时器</em> Handler的使用: 1,定义Handler重载handleMessage方法,handleMessage为处理消息的方法,如下: private Handler handler = new Handler(){ @Override public void handleMessage(Message msg) { show.s
Handler和TimerTask实现的简易定时器
用Handler和Timertask实现一个简单的<em>定时器</em>,一个简单的demo
jsp出现java.lang.NullPointerException 异常
public ActionForward doSelectteacher(ActionMapping mapping, ActionForm form,rn HttpServletRequest request, HttpServletResponse response) rn Map map = new HashMap();rn try rn int teacherId = Integer.parseInt(request.getParameter("id"));//这里id可以取到rn System.out.print("teacherId="+teacherId);rn String sql="from Teacher where teacherId = "+teacherId+"";rn System.out.println(sql);rn [color=#FF0000] List teachers = teacherDAO.findByHQL(sql);[/color][color=#FF0000]单步调试只能到这里,再往下就直接报<em>异常</em>java.lang.NullPointerException [/color]rn Teacher teacher = teachers.get(0);rn if(teacher != null) rn int courseId = teacher.getCourseId(); rn DetachedCriteria dc = org.hibernate.criterion.DetachedCriteria.forClass(Teacher.class);rn dc.createAlias("coursse", "cou");rn dc.add(Restrictions.eq("cou.courseId", courseId));rn Page.util( request, achievementService,dc,"dataList","param=doSelect",map,Page.PAGESIZE);//分页rn rn return mapping.findForward("show");rn catch (Exception e) rn request.setAttribute("exceptions",e);rn return mapping.findForward("exceptions");rn rn rnrnhibernate配置都是正常的,可以正常连接,有teacher和course表,teacher通过courseId和course关联,DEBUG调试可以运行到以上红色,再往下就直接捕获<em>异常</em>显示了
异常:java.lang.NullPointerException 到底是怎么回事?
当我在一个JSP文件中运行到 stmt=con.createStatement(); 这句语句时,就会出现以下<em>异常</em>:java.lang.NullPointerException .rn请问这是怎么回事?
java.lang.NullPointerException 异常原因
private String[] getGroupValue(PageContext pageContext)throws LogicExceptionrn tryrn ServletRequest request = pageContext.getRequest();rn String id[] = request.getParameterValues("group");rn return id;rn catch(Exception ex)rn String sErr = new ErrorMessageApp().getMessage("2009");rn sErr = CommonTools.stringFirstReplace(sErr,"1%","Exception");rn sErr = CommonTools.stringFirstReplace(sErr,"2%",ex.getMessage());rn throw new LogicException(sErr);rn rn rnrn private int getUserId()throws LogicExceptionrn Connection conn = null;rn tryrn conn = this.getConnection();rn Statement stmt = conn.createStatement();rn ResultSet rs = stmt.executeQuery("select count(*) from tbluser");rn rs.next();rn int result = rs.getInt("count(*)");rn rs.close();stmt.close();rn result++;rn return result;rn catch(Exception ex)rn String sErr = new ErrorMessageApp().getMessage("2009");rn sErr = CommonTools.stringFirstReplace(sErr,"1%","Exception");rn sErr = CommonTools.stringFirstReplace(sErr,"2%",ex.getMessage());rn throw new LogicException(sErr);rn finallyrn this.freeConnection(conn);rn rn rnrnrnpublic boolean addUser(PageContext pageContext)throws LogicExceptionrn ServletRequest request = pageContext.getRequest();rn int id = this.getUserId();rn String name = request.getParameter("sub_name");rn name = CodeTool.ISOtoGBK(name);rn String password = request.getParameter("sub_password");rn password= ( new ForumMD5() ).getMD5ofStr( password );rn String gender = request.getParameter("sub_gender");rn String birthday = request.getParameter("birthday");rn String unit = request.getParameter("sub_unit");rn unit = CodeTool.ISOtoGBK(unit);rn String mobile = request.getParameter("sub_mobile");rn String phone = request.getParameter("sub_phone");rn String address = request.getParameter("sub_address");rn address = CodeTool.ISOtoGBK(address);rn String zipcode = request.getParameter("sub_zipcode");rn String memo = request.getParameter("sub_memo");rn String station = request.getParameter("sub_ip");rn memo = CodeTool.ISOtoGBK(memo);rn String group[]= this.getGroupValue(pageContext);rn Connection conn=null;rn tryrn conn = this.getConnection();rn Statement stmt=conn.createStatement();rn String sql = "insert into tbluser (id,password,name,gender,unit,birthday,mobile,wphone,address,zipcode,memo) values"rn +"('"+id+"','"+password+"','"+name+"','"+gender+"','"+unit+"','"+birthday+"','"+mobile+"','"+phone+"','"+address+"','"+zipcode+"','"+memo+"')";rn stmt.addBatch(sql); rn for( int i=0; i
定时任务:Timer类、TimerTask类
/** * 每隔5秒就启动一次QQ */public class Test { public static void main(String[] args){ Timer timer = new Timer(); timer.schedule(new MonitorInfraredTask(), 0, 5*1000); //每隔5秒启动QQ } }
Springdata+jpa读取mysql数据库代码抛java.lang.NullPointerException错误
测试主函数:rn@SpringBootApplicationrnpublic class unitTestApplication rn public static void main(String[] args)rn rn ProvinceService provinceService = new ProvinceService();rn Province province = new Province();rn [b]provinceService.queryProvince(province); [/b]rn rnrnrnservice层:rn@Servicernpublic class ProvinceService rnrn @Autowiredrn public ProvinceRepository provinceRepository;rn rn @PersistenceContextrn public EntityManager entityManager;rnrn //查询省份信息rn public Province queryProvince(Province province) rnrn [b]List provinceinfo = provinceRepository.findAll();[/b] rn Province provinceresult = provinceinfo.get(0); rn return provinceresult;rn rnrnrndao层:rn@Transactionalrnpublic interface ProvinceRepository extends JpaRepository rn public List findAll();rnrnrnentity层:rn@Entityrnpublic class Province rn @Idrn @GeneratedValuern private Long provinceId;rnrn @Column(nullable = false)rn private String provinceName;rnrn public Province() rnrn public Province(String provinceName) rn this.provinceName = provinceName;rn rn rn @Column(name="province_id")rn public Long getProvinceId() rn return provinceId;rn rnrn public void setProvinceId(Long provinceId) rn this.provinceId = provinceId;rn rn rn @Column(name="province_name")rn public String getProvinceName() rn return provinceName;rn rnrn public void setProvinceName(String provinceName) rn this.provinceName = provinceName;rn rnrnrnrnrn运行主函数,报错如下:rnException in thread "main" java.lang.NullPointerExceptionrn at com.wherever.service.ProvinceService.queryProvince(ProvinceService.java:29)rn at com.wherever.unitTestApplication.main(unitTestApplication.java:22)rnrn代码很简单,小弟初学springboot,初次接触jpa+springdata来管理数据库,请各位大神指教,感激不尽!!!
.NET JS抛异常
      void   Page_Load(object   src,EventArgs   e){}     void   test_click(object   src,EventArgs   e){     throw   new   ApplicationException("出错啦");     }       
sqlserver2005 open抛异常
_ConnectionPtr m_pConnection;rn tryrn rn //´创建connection连接对象rn m_pConnection.CreateInstance("ADODB.Connection"); rn //设置连接字符串rn _bstr_t strConnect= "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Test;Data Source=C56BD99225E74C6;Initial File Name=D:\Project2008\Adotest\Adotest\Test.mdf";rn AfxMessageBox(strConnect, 0, 0);rn //SERVER和UID,PWD的设定需要根据自己的情况rn m_pConnection->Open(strConnect, "", "", adModeUnknown); rn rn //捕捉<em>异常</em>rn catch(_com_error e)rn rn //显示错误信息rn AfxMessageBox(e.Description());rn rn弹出消息框rn“D:\Project2008\Adotest\Adotest\Test.mdf”已存在rn请问大家,为什么抛<em>异常</em>,Open()函数的作用和各个参数的含义rn请大家帮忙,谢谢!
oracle手动抛异常
---------------------------------------阶段3---------------------------------------------------------------------------------------------- declare v_dept dept%rowtype; begin v_dept.deptno:=&deptno;
try里面抛异常
public class Demo{ static String o=""; static void fuck(int i) { try{ if(i==1) throw new Exception(); } catch(Exception e) { o+=2; return; } finally{ o+=3;
异常的正确姿势
每个程序员都会抛<em>异常</em>的<em>问题</em>吧!但如果抛的姿势不对,会很烦呐!就在刚刚,我才知道我抛<em>异常</em>的姿势很不对。 我以前没有打印<em>异常</em>日志的习惯,直到我看到别人打印日志,我也开始打印了。不得不说这样做确实不错,程序出<em>问题</em>了,只要看看日志就能明白个大概是哪里错了。 但是有个<em>问题</em>是,我只是把导致<em>异常</em>的原因打印出来了,所以当有<em>异常</em>的出现的时候,虽然知道是出了什么错,但,并不知道是哪个模块出<em>问题</em>了!这是
类型转换抛异常~!!!
string 转换为 long 型。出现<em>异常</em>。rnrn[code=Java]rnLong deptId = new Long(request.getParameter("deptId"));rn[/code]rnrnexception rnrnjava.lang.NumberFormatException: nullrn java.lang.Long.parseLong(Unknown Source)rn java.lang.Long.(Unknown Source)rn求解
_RecordsetPtr Open抛异常
_RecordsetPtr Open抛<em>异常</em>rn以下是相关代码rnrnBOOL CAdoTestDlg::OnInitDialog()rnrn CDialog::OnInitDialog();rnrn // 将“关于...”菜单项添加到系统菜单中。rnrn // IDM_ABOUTBOX 必须在系统命令范围内。rn ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);rn ASSERT(IDM_ABOUTBOX < 0xF000);rnrn CMenu* pSysMenu = GetSystemMenu(FALSE);rn if (pSysMenu != NULL)rn rn CString strAboutMenu;rn strAboutMenu.LoadString(IDS_ABOUTBOX);rn if (!strAboutMenu.IsEmpty())rn rn pSysMenu->AppendMenu(MF_SEPARATOR);rn pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);rn rn rnrn // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动rn // 执行此操作rn SetIcon(m_hIcon, TRUE); // 设置大图标rn SetIcon(m_hIcon, FALSE); // 设置小图标rnrn // TODO: 在此添加额外的初始化代码rn if (!AfxOleInit())rn rn AfxMessageBox(_T("初始化失败!"));rn return FALSE;rn rnrn tryrn rn //´创建connection连接对象rn // m_pConnection.CreateInstance("ADODB.Connection"); rn m_pConnection.CreateInstance(_uuidof(Connection));rn //设置连接字符串rn _bstr_t strConnect= "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Test;Data Source=孙健;Initial File Name=E:\\公司界面试验版\\AdoTest\\Test.mdf";rn // AfxMessageBox(strConnect,0,0);rn // SERVER 和 UID,PWD的设定需要根据自己的情况rn m_pConnection->Open(strConnect, "", "", adModeUnknown);rnrn rn //捕捉<em>异常</em>rn catch(_com_error e)rn rn //显示错误信息rn AfxMessageBox(e.Description());rn rnrn return TRUE; // 除非将焦点设置到控件,否则返回 TRUErnrnrnBOOL CAdoTestDlg::OpenRecordSet(_RecordsetPtr &recPtr, CString &strSQL)rnrn CAdoTestApp* pApp = (CAdoTestApp*)AfxGetApp();rn // 创建记录集对象rn m_pRecordset.CreateInstance(__uuidof(Recordset));rn // 在ADO操作中建议语句中要常用try...catch()来捕获错误信息,rn // 因为它有时会经常出现一些想不到的错误rn tryrn rn // 从数据库中打开表rn recPtr->Open(strSQL.AllocSysString(), rn pApp->m_pConnection.GetInterfacePtr(),rn adOpenDynamic,rn adLockOptimistic,rn adCmdText);rn rn catch (_com_error e)rn rn CString strError;rn strError.Format(_T("警告:打开数据表时发生<em>异常</em>。 错误信息: %s"),\rn e.ErrorMessage());rn AfxMessageBox(strError);rn return FALSE;rn rn return TRUE;rnrnrnrnvoid CAdoTestDlg::OnBnClickedButtonInsert()rnrn // TODO: Add your control notification handler code herern CString strSQL;rn UpdateData(TRUE);rn // 打开纪录集,选择表名rn strSQL = "select * from Name";rn if (!OpenRecordSet(m_pRecordset, strSQL))rn rn AfxMessageBox(_T("没有成功打开数据表"));rn return ;rn rn tryrn rn m_pRecordset->AddNew();rn m_pRecordset->PutCollect("Name", _variant_t(m_strInsert));rn rn catch(_com_error e)rn rn CString strError;rn strError.Format(_T("警告:插入信息时发生<em>异常</em>。错误信息。%s"), e.ErrorMessage());rn AfxMessageBox(strError);rn rn m_pRecordset->Close();rn m_pRecordset = NULL;rn AfxMessageBox(_T("插入成功!"));rnrnrn此处Open抛<em>异常</em>rn // 从数据库中打开表rn recPtr->Open(strSQL.AllocSysString(), rn pApp->m_pConnection.GetInterfacePtr(),rn adOpenDynamic,rn adLockOptimistic,rn adCmdText);rn请大家给予帮助,谢谢rn还有一个<em>问题</em>,我最近刚学数据库,怎么在MSDN中没有发现_RecordsetPtr, _CommandPtr, _ConnetionPtr阿rn如何查找它们阿
异常 throw的注意事项
子类覆盖父类只能抛出父类的<em>异常</em>或者子类或者子集注意:如果父类的方法没有抛<em>异常</em>,那么子类覆盖时绝对不能抛。子类继承父类时,方法抛<em>异常</em>,要么抛父类,要么抛父类下的子类,不能抛父类平级或以上的<em>异常</em>原因是多态的向上,向下转型 转载于:https://www.cnblogs.com/liyunchuan/p/10683873.html...
异常,与捕获的使用情况
throws throw 是无法处理的情况下往上一层抛<em>异常</em>try catch是自己可以解决时使用,就直接 try catch 转载于:https://www.cnblogs.com/liyunchuan/p/10674419.html
java抛异常
最近有个需求,当发现程序不能按预期执行,需要立即退出并显示错误地点和信息,修改代码后再重新运行。 调研了下,用throw RuntimeException<em>异常</em>的方法就可以 public static void throwone() throws RuntimeException { throw new RuntimeException("so board"); } 调用的时候不要t
关于异常上抛
原理:<em>异常</em>在底层被拦截了,将不会上抛至上层。   如以下示例,A调用B的方法,B方法会出错,我在B中已拦截了,那么在A中将看拦截不到<em>异常</em>。         B代码: package testexceptionthrows; public class B { public void go() throws Exception{ try { System.ou...
C# 线程抛异常
<em>异常</em>抛出 <em>异常</em>抛出要在线程代码中抛出,否则捕获不到 using System; using System.Threading; namespace testthread_keyword_lock { class Program { static void Main(string[] args) { //<em>异常</em>可以捕获 ...
php?抛异常
[code=php]rnthrow new CHttpException(400,'This category-title is use on sub-category management');rn[/code]rn[img=https://img-bbs.csdn.net/upload/201509/23/1442970952_860321.png][/img]rnrn怎么把[color=#FF0000] Error 400:[/color] 去掉??
异常与重写
无论是继承Thread 的run方法还是实现runnable接口的run方法,都不能抛出<em>异常</em>;原因是因为重写方法抛<em>异常</em>的范围不能发育被重写方法抛<em>异常</em>的范围;这句话怎么理解哦?
联通短信接口抛异常
使用中兴的jar调联通短信接口时出现<em>异常</em>SGIPSubmitResp message:rnMessage Length = 0rnCommand ID = -2147483645rnSequence Number = 7 827134627 2rnResult = -4rnReserve = rnrnERROR [Thread-12] com.zte.smgw.socket.client.SocketClientLink null - SockectClientLink read message error,key:sun.nio.ch.SelectionKeyImpl@12e6b414rn java.io.IOException: 远程主机强迫关闭了一个现有的连接。rn at sun.nio.ch.SocketDispatcher.read0(Native Method)rn at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)rn at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:225)rn at sun.nio.ch.IOUtil.read(IOUtil.java:198)rn at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:359)rn at com.zte.smgw.socket.client.SocketClientLink.read(SocketClientLink.java:141)rn at com.zte.smgw.socket.client.SocketClientLink.run(SocketClientLink.java:125)rn at java.lang.Thread.run(Thread.java:722)rnrnrnrn求高手帮忙,急急急
约束 抛异常
# -----------------------凡事在成熟之前,都是有苦味的.---------------------------# day 19 #项目经理# class Base:# def login(self):# raise NotImplementedError("子类没有实现该方法") #报错.抛<em>异常</em>### # 普通登录--&gt;# class N...
Python大法之抛 异常
python提供了两个非常重要的功能来处理python程序在运行中出现的<em>异常</em>和错误。你可以使用该功能来调试python程序。 我们来看下都有哪些<em>异常</em>: python标准<em>异常</em> <em>异常</em>名称描述 BaseException 所有<em>异常</em>的基类 SystemExit 解释器请求退出 KeyboardInterrupt 用户中断执行(通常是输入^C) Exc...
throw抛异常
格式:throw new <em>异常</em>名 1.当<em>异常</em>名为Exception(包括了受检<em>异常</em>和非受检<em>异常</em>)时,必须try...catch...此<em>异常</em>,或者抛给(throws)方法,谁调用这个方法谁处理。 2.当<em>异常</em>名为RuntimeException(非受检<em>异常</em>)时,可以不try...catch...此<em>异常</em>,也可以不抛给(throws)方法,即:处理不处理都可以。
iOS断言-抛异常
自定义描述<em>异常</em>信息的desc就是所谓的抛<em>异常</em> 注意:assert是一个宏,只在debug版本中起作用,在release版本中,该语句是不起任何作用的。 示例一:给Label属性赋值不能为空,添加断言,如果为空,则直接crash,抛<em>异常</em> #import "MainViewController.h" @interface MainViewController () @property(non
析构函数中抛异常
 1: 可以在析构函数中抛<em>异常</em>吗?        不可以!        虽然语法上并没错,但会对整体系统带来重大隐患!! 2: 那么如何保证析构不抛<em>异常</em>呢?       2.1)析构里如同构造函数一样,做一些简单的操作。       2.2)如果<em>异常</em>不可避免,那么直接在析构里捕获<em>异常</em>,不要让<em>异常</em>逃离析构函数! 3: 析构里抛<em>异常</em>有什么危害呢?       阻止<em>异常</em>传递到析构函数外有两个原因,
Java初学之抛异常
有这样一道题: 下面关于try、catch和finally语句块的组合使用,正确的是  (A)try {…}  (B)try {…} finally {…} (C)try {…} catch {…} finally {…} (D)try {…} catch {…} catch {…}  答案:BCD 我们通过这个题,来详细的了解一下Java中抛<em>异常</em>: 任何Java代
finally块与抛异常
复习一下finally块里有return和try抛<em>异常</em>的程序执行顺序<em>问题</em>.首先看一个测试例子:public class FinallyTryTest { public static void main(String[] args) { int a=testFinally(); System.out.println(a); } public s...
XA_atomikos能抛的异常
XA_atomikos能抛的<em>异常</em>xa的Resource挂了 xa的Resource挂了 Cause:com.atomikos.datasource.ResourceException:
事物里面抛异常
[b][color=#FF00FF][/color][/b今天试验了一下,查询,删除,更新失败之后不会主动抛<em>异常</em>,只有添加失败才会rn求确认,是不是这样子的
我的Jboss抛异常
7:12,796 ERROR [AbstractKernelController] Error installing to Real: name=vfsfile:/F:/jboss-5.0.0.GA/server/default/deploy/user.war/ state=PreReal mode=Manual requiredState=Realrnorg.jboss.deployers.spi.DeploymentException: URL vfsfile:/F:/jboss-5.0.0.GA/server/default/deploy/user.war/ deployment failedrn at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:388)rn at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:146)rn at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:460)rn at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)rn at org.jboss.web.deployers.WebModule.start(WebModule.java:96)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)rn at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)rn at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)rn at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)rn at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)rn at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)rnrnrnrnrn环境变量我是这样配的rn环境变量配置如下:rnJBOSS_HOME:F:\jboss-5.0 rn rnPATH:%SystemRoot%\system32;%SystemRoot%;
内部错误怎么抛异常
UI层调用逻辑层接口发送一些命令。rn逻辑层中对一些指针进行判断,发现为null,抛出<em>异常</em>。rnrn但是这些指针并不是ui操作的,而是自身在初始化的时候可能代码写的不对,有些对象没有初始化引起<em>异常</em>。rn所以如果把<em>异常</em>抛给ui,感觉不应该是ui的事啊,ui根本就不知道有这些指针存在。rn这个时候该怎么处理呢。rnrn不抛<em>异常</em>给ui,但是ui的指令已经无法正确执行了。不抛的话ui不知道程序出错,还傻乎乎以为好使,实际已经不能执行命令了。rn抛出<em>异常</em>给ui,抛什么呢。抛指针为空<em>异常</em>,ui根本不知道哪来的指针,会让ui一头雾水。抛个innererror,还是一头雾水,不知道怎么处理。rnrn客户使用这个ui,最好有一个容易让客户接受的方法来处理这个错误。rn也就是说,我的程序出错了,还想让客户比较好接受一点。rnrn开始想法是不抛<em>异常</em>,记录日志,客户发现程序命令不能执行,但是不知道怎么回事。联系我们,我们去看日志,改程序。rnrn另外:一个命令不能执行,有可能可以通过其他命令完成同样的操作。比如。有一组开关,群开功能出现<em>异常</em>,不能执行,但是单开好使。这样客户操作群开发现不能打开开关,就用单开一个一个打开,然后告诉我们群开不好使,然后我们去改程序。rnrn大家是怎么在程序中处理程序自身引起的<em>异常</em>的。
String.valueOf()抛NumberFormatException异常
[code=java]temp = String.valueOf(Double.parseDouble(left)*Double.parseDouble(right));[/code]rn其中left、right都是string类型的数字。rn为什么会抛NumberFormatException<em>异常</em>
ICSharpCode压缩抛异常
<em>异常</em>信息:Exception of type 'System.OutOfMemoryException' was thrown.rn引发当前<em>异常</em>的方法: Void zip(System.String, System.String, ICSharpCode.SharpZipLib.Zip.ZipOutputStream)rn<em>异常</em>实例: 缺省rn<em>异常</em>堆栈: at YIYOU.DAL.Zip.zip(String strFile, String StoreFile, ZipOutputStream s)rn at YIYOU.DAL.Zip.ZipFilenew(String strFileFolder, String strZip)rn at YIYOU.UI.UserFr.FrToolsEdit.ToolsAdd(String& Msg)rnrnrn=======rn以上是错误提示 ,环境为xp系统. 压缩超过500m的文件就抛该<em>异常</em>. rnwin7上压缩则不会 ,求帮助.
python tornado3.1抛异常
跑<em>异常</em>的地方是个循环,循环条件是字典非空,但在pop时却是空的,很奇怪。rntornado使用了线程池ThreadPoolExecutor,不确定有没有关系。rn请大牛指点,一直没看出来哪里的<em>问题</em>。谢谢rnrn<em>异常</em>信息如下:rnTraceback (most recent call last):rnFile "webserver.py", line 64, in rnmain()rnFile "webserver.py", line 57, in mainrn tornado.ioloop.IOLoop.instance().start()rnFile "/home/cov/tools/python/lib/python2.7/site-packages/tornado-3.1-py2.7.egg/tornado/ioloop.py", line 670, in startrnfd, events = self._events.popitem()rnKeyError: 'popitem(): dictionary is empty'rnrnrn抛<em>异常</em>源码如下:rn while self._events:rn fd, events = self._events.popitem()rn try:rn self._handlers[fd](fd, events)rn except (OSError, IOError) as e:rn if e.args[0] == errno.EPIPE:rn # Happens when the client closes the connectionrn passrn else:rn app_log.error("Exception in I/O handler for fd %s",rn fd, exc_info=True)rn except Exception:rn app_log.error("Exception in I/O handler for fd %s",rn fd, exc_info=True)
按键 keyPressed抛异常!!!
code = -3rnjava.lang.IllegalArgumentExceptionrn at javax.microedition.lcdui.Canvas.getKeyCode(+16)rn at com.farm.mobile.GameControl.getKeyCode(+5)rn at com.farm.mobile.GameControl.keyPressed(+27)rn at javax.microedition.lcdui.Canvas.callKeyPressed(+19)rn at javax.microedition.lcdui.Display$DisplayAccessor.keyEvent(+198)rn at javax.microedition.lcdui.Display$DisplayManagerImpl.keyEvent(+11)rn at com.sun.midp.lcdui.DefaultEventHandler.keyEvent(+127)rn at com.sun.midp.lcdui.AutomatedEventHandler.keyEvent(+210)rn at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.handleVmEvent(+114)rn at com.sun.midp.lcdui.DefaultEventHandler$QueuedEventHandler.run(+57)rnrnrnrn代码如下 :rnrn public void keyPressed(int keyCode)rn System.out.println("code = "+keyCode);;rn int key = this.getKeyCode(keyCode);rn System.out.println("key = "+ " :: code= ");rn rn rn rnrn真不知道哪里错了<em>问题</em>了 忘各位大虾指正 谢谢
[初学者]为什么这个程序会抛“java.lang.NullPointerException”?
MyFirstMIDlet1.javarn[code]rnimport javax.microedition.midlet.*;rnimport javax.microedition.lcdui.*;rnrnpublic class MyFirstMIDlet1 extends MIDletrnrn private Display myDisplay;rn rn public void MyFirstMIDlet1()rn rn myDisplay = Display.getDisplay(this);rn rnrn public void startApp()rn rn Form myForm = new Form("MyFirstMIDlet1");rn myDisplay.setCurrent(myForm);rn rnrn public void pauseApp()rn rn public void destroyApp(boolean unconditional)rn rn notifyDestroyed();rn rnrn[/code]rn这个程序运行时有错“java.lang.NullPointerException”,而下面这个程序没有!rnMyFirstMIDlet2.javarn[code]rnimport javax.microedition.midlet.*;rnimport javax.microedition.lcdui.*;rnrnpublic class MyFirstMIDlet2 extends MIDletrnrn public void MyFirstMIDlet2()rn rn rnrn public void startApp()rn rn Displayable current = Display.getDisplay(this).getCurrent();rn if(current == null)rn rn Form myForm = new Form("MyFirstMIDlet");rn Display.getDisplay(this).setCurrent(myForm);rn rn rnrn public void pauseApp()rn rn public void destroyApp(boolean unconditional)rn rn notifyDestroyed();rn rnrn[/code]rn有没有哪位好心人指点一下,谢谢!
magento 自己抛异常
调用magento自带的<em>异常</em> Mage::throwException
_ConnectionPtr Open抛异常
BOOL CPracticeApp::ConnectionDB()rnrn HRESULT hr = m_connectionPtr.CreateInstance("ADODB.Connection"); rn if (FAILED(hr))rn rn return FALSE;rn rn _bstr_t strConnect = "driver=SQL Server; Server = 孙健; Database = E:\\allen\\Practice\\Practice\\DataBase\\Student_Data; uid = "", pwd = "";";rn tryrn rn m_connectionPtr->Open(strConnect, "", "", adModeUnknown);rn rn catch(_com_error e)rn rn AfxMessageBox(e.Description());rn rn return TRUE;rnrn以上是我写的代码,执行到Open的时候会抛出<em>异常</em>,请问大家如何解决阿,我想用ado访问sqlserver2005rn希望有会的高手帮我看看
Integer.parseInt()抛异常??
String TestStr="8";rnrnint testInt=Integer.parseInt(TestStr, 2);rn rnint temp=Integer.valueOf(TestStr, 2).intValue();rnrn上面两个 都会报错....rn 求解!
struts上传抛异常
今天在写项目的时候出现了一个这样的错误,不知道是怎么回事,后来在网上找资料发现了解决方法: struts.multipart.saveDir没有配置。 struts.multipart.saveDir用于指定存放临时文件的文件夹,该配置写在struts.properties文件中。例如,如果在struts.properties文件加入如下代码: struts.multipart.save...
J2ME 纵版飞行射击游戏下载
在学习J2ME过程中编写的纵版飞行射击类游戏,只有1关,并没有做很全,但应有的功能差不多都有了。 相关下载链接:[url=//download.csdn.net/download/liuliuyu226/2339321?utm_source=bbsseo]//download.csdn.net/download/liuliuyu226/2339321?utm_source=bbsseo[/url]
Toad for DB2 4.7 Trial正式版+注册机+连接配置方式.part4.rar下载
弄了一个星期终于把toad for db2 运行起来了 把资源上传上来与大家分享 奈何只能分割成小于15M的 大家忍忍吧 连接配置方式.excel文件中是我的toad链接配置方式 比Aqua Data Studio 和ibm_data_studio_standalon好用多了 不是一个档次 很全 放心用吧 相关下载链接:[url=//download.csdn.net/download/redbull_250ml/2944923?utm_source=bbsseo]//download.csdn.net/download/redbull_250ml/2944923?utm_source=bbsseo[/url]
Weka的操作手册下载
使用Weka,进行数据挖掘,这是一个详细的操作手册,非常清楚,非常有用的。 相关下载链接:[url=//download.csdn.net/download/doudou_shizizuo/4904845?utm_source=bbsseo]//download.csdn.net/download/doudou_shizizuo/4904845?utm_source=bbsseo[/url]
我们是很有底线的