JUST DO IT ~

我只想当个程序员



TMD 到底什么是异常


程序按照预期的流程运行..正常态
出现未预计到的情况..比如网线断了gddg...文件打开失败...
这个时候 程序是继续执行 还是 其他的选择 或者 退出app ....

实际的情况是 有可能可以恢复,从业务角度出发..我可以重新试图连接...可以重新打开文件或者换一个文件 或者重新创建一个新的文件....
只要不是致命的问题..通常是可以恢复的...没必要退出app...

如果你不捕获 网络断开或者文件无法打开的 异常 ...那么为什么程序退出了呢...因为你没有告诉你的程序 如果出错了应该怎么办...sun 规避风险,你出错了,可能下一步要错误的扣除你工资,为了解除这种不确定执行的巨大风险...那么就把你app shutdown了....

如果你有catch 对于程序来说 你有防备 出现异常的准备...那么真到了异常 那么就看你异常的处理流程 是否奏效....

异常体系....瞎扯淡...就是几个异常类的继承关系(虚拟机内部异常,用户定义异常 ...).....还能有什么 .
无非是 根据不同的出错类型来 包装异常...给这个这种类型的异常 或者 这类问题取一个名字....
当你没看堆栈信息的时候大概可以 判断一下 问题再那里而已.....


异常来跳转 程序是因为 无法预期异常后下步该如何执行 所以跳转...
异常是比较消耗系统资源的.


.net 为什么没有主动要求你 抛出异常....
因为.net的主要架构师 再设计.net时候看到了 很多程序员 一层一层的抛出异常只在最底层  main中截获异常....
那么大量的函数都是 throws 其实根本无意义....所以他再设计的时候就没有采取和java 相同的方式 .



 




posted @ 2009-10-10 01:07 小高 阅读(332) | 评论 (2)编辑 收藏

片段 "


 public LocationInfo(Type callerStackBoundaryDeclaringType)
  {
   // Initialize all fields
   m_className = NA;
   m_fileName = NA;
   m_lineNumber = NA;
   m_methodName = NA;
   m_fullInfo = NA;

#if !NETCF
   if (callerStackBoundaryDeclaringType != null)
   {
    try
    {
     StackTrace st = new StackTrace(true);
     int frameIndex = 0;

     // skip frames not from fqnOfCallingClass
     while (frameIndex < st.FrameCount)
     {
      StackFrame frame = st.GetFrame(frameIndex);
      if (frame != null && frame.GetMethod().DeclaringType == callerStackBoundaryDeclaringType)
      {
       break;
      }
      frameIndex++;
     }

     // skip frames from fqnOfCallingClass
     while (frameIndex < st.FrameCount)
     {
      StackFrame frame = st.GetFrame(frameIndex);
      if (frame != null && frame.GetMethod().DeclaringType != callerStackBoundaryDeclaringType)
      {
       break;
      }
      frameIndex++;
     }

     if (frameIndex < st.FrameCount)
     {
      // now frameIndex is the first 'user' caller frame
      StackFrame locationFrame = st.GetFrame(frameIndex);

      if (locationFrame != null)
      {
       System.Reflection.MethodBase method = locationFrame.GetMethod();

       if (method != null)
       {
        m_methodName =  method.Name;
        if (method.DeclaringType != null)
        {
         m_className = method.DeclaringType.FullName;
        }
       }
       m_fileName = locationFrame.GetFileName();
       m_lineNumber = locationFrame.GetFileLineNumber().ToString(System.Globalization.NumberFormatInfo.InvariantInfo);

       // Combine all location info
       m_fullInfo =  m_className + '.' + m_methodName + '(' + m_fileName + ':' + m_lineNumber + ')';

      }
     }
    }
    catch(System.Security.SecurityException)
    {
     // This security exception will occur if the caller does not have
     // some undefined set of SecurityPermission flags.
     LogLog.Debug("LocationInfo: Security exception while trying to get caller stack frame. Error Ignored. Location Information Not Available.");
    }
   }
#endif
  }





posted @ 2009-10-01 00:02 小高 阅读(313) | 评论 (0)编辑 收藏
C# Preprocessor Directives
http://msdn.microsoft.com/en-us/library/ed8yd1ha.aspx

#if

#else

#elif

#endif

#define

#undef

#warning

#error

#line

#region

#endregion

#pragma

#pragma warning

#pragma checksum



#if NETCF

Console.WriteLine(message);

//System.Diagnostics.Debug.WriteLine(message);

#else

Console.Error.WriteLine(message);

Trace.WriteLine(message);

                System.Diagnostics.Debug.

#endif


posted @ 2009-09-30 13:05 小高 阅读(151) | 评论 (0)编辑 收藏


时间

select
trunc(86400*
  (to_date('2009-1-1 23:15:01','yyyy-mm-dd hh24:mi:ss') -
 to_date('2009-1-1 23:10:00','yyyy-mm-dd hh24:mi:ss'))
 )
from dual ;

posted @ 2009-09-12 09:19 小高 阅读(359) | 评论 (0)编辑 收藏
在启动时关闭sendmail 服务 [其它服务也一样]
posted by JianNeng in Opensource 在启动时关闭sendmail- -

对其他的服务可以采取同样的措施。 

  而对于那些不是从inetd启动的服务,则通过命令来关闭,例如需要关闭sendmail服务,则:

/etc/rc.d/init.d/sendmail stop

  然后再设置其不在系统启动时启动:

chkconfig -levels 12345 sendmail off

[root@oracle xinetd.d]# chkconfig --level 123456  sendmail off
[root@oracle xinetd.d]# 
linux 关机 

[root@oracle ~]# shutdown -h now

posted @ 2009-09-07 08:22 小高 阅读(863) | 评论 (0)编辑 收藏
     摘要: plsql developer plsql 调试无法 ..包没加入所有的函数的定义到 包头文件定义.   阅读全文
posted @ 2009-08-25 20:18 小高| 编辑 收藏
     摘要: 为什么log4j 显示行号
(2) 建立一个Throwable的对象来取得当前运行堆栈的快照...Throwable.fillInStackTrace();
(3) 从抛出的Throwable对象中,来分析出当前log信息的行号...  阅读全文
posted @ 2009-08-18 20:21 小高 阅读(647) | 评论 (0)编辑 收藏
     摘要: 其实,很简单,并不是因为系统打了补丁的问题,而是因为VS 2008打了补丁,导致没法删除,可以在“添加/删除程序”面板中,选中上方的“显示更新”,然后找到VS 2008,下面多多少少会挂了几个更新或者补丁,全部先删掉,然后再删VS 2008,熟悉的维护界面又回来了,输入序列号,OK,正常使用~~~  阅读全文
posted @ 2009-07-17 14:31 小高 阅读(2038) | 评论 (2)编辑 收藏
     摘要: lsnrctl services  阅读全文
posted @ 2009-02-26 20:47 小高 阅读(3797) | 评论 (1)编辑 收藏
     摘要: sqlplus Xdmp/Xdmp@127.0.0.1:1521/Xdmp
SQL> conn sys/oracle @itmp_rac as sysdba  阅读全文
posted @ 2009-02-24 16:04 小高 阅读(1639) | 评论 (3)编辑 收藏
     摘要: 左连接 .如果一边的没有记录, nvl (右边,0) 否则会造成整列无法,无数据.

select d.crunit_ - nvl( a.stkamt_ ,0)
from dl_fundetf d ,
(select c.stkcode_, c.exchgcode_,c.stkamt_ ,c.stkcost_
from acc_proflstk c
where 1=1
and c.fundid_ = '55'
and c.cellid_ = '50001'
and c.proflid_ = '080724113732'
) a
where 1=1
and d.exchgcode_ = 'SH'
and d.fundid_ = '510051'
and a.exchgcode_ (+)= d.exchgcode_
and a.stkcode_ (+)= d.fundid_   阅读全文
posted @ 2009-02-10 15:07 小高 阅读(774) | 评论 (0)编辑 收藏
     摘要: 1.作用: 屏蔽方法名 ,灵活性动态性函数指针

2 .使用:

定义一个委托: 和一个类一样的

delegatevoid Del (int x);

或者

delegatevoid Del (T x);

定一个委托变量和赋值

Main(){

Del d = obj.DoWork; 实例方法或者静态方法都可以

}
  阅读全文
posted @ 2009-02-01 11:06 小高 阅读(218) | 评论 (0)编辑 收藏
     摘要:   阅读全文
posted @ 2008-12-04 16:31 小高 阅读(224) | 评论 (0)编辑 收藏
     摘要:   阅读全文
posted @ 2008-11-04 21:52 小高 阅读(168) | 评论 (0)编辑 收藏
     摘要: 检查客户机器上的输入法区域设置。如果默认输入法不是中文,则先调用一下方法,切换到中文。
Top

  阅读全文
posted @ 2008-10-22 20:02 小高 阅读(427) | 评论 (0)编辑 收藏
仅列出标题
共20页: First 上一页 10 11 12 13 14 15 16 17 18 下一页 Last 

导航

<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

统计

常用链接

留言簿(3)

随笔分类(352)

收藏夹(19)

关注的blog

手册

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜