`
zsj01005432
  • 浏览: 42499 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

经验总结

    博客分类:
  • java
阅读更多
1.
  List<String> lst=new ArrayList<String>();
  System.out.println(lst.get(0));
 [color=red]你一定以为这个返回只是个null值,其实错了,这个直接就报异常了~~~[/color]            

2.
    create table APP_REPORT_NODES (
   objectid     number(10) not null default -1,
   ipaddr     varchar2(50) not null default '',
   rpt_id number(10) not null,
   ifindex varchar2(50) default ''
   );
   

   咋看之下这建表语句好像没什么问题,但是当你运行的时候,你会发现丫的居然报缺失右括号- -!错的地方就在于default应该放在not null 之前。
   正确的是:
   create table APP_REPORT_NODES (
   objectid     number(10) default -1 not null  ,
   ipaddr     varchar2(50) default ' ' not null  ,
   rpt_id number(10) not null, 
   ifindex varchar2(50) default ' '
);
   

  还有就是 当设置默认值为空字符串的时候,最好打个空格上,不然当你插入记录而当有默认值的那列且not null 的时候,会报约束错误。
3 oracle  to_date函数:
在使用Oracle的to_date函数来做日期转换时,很多Java程序员也许会和我一样,直觉的采用“yyyy-MM-dd HH:mm:ss”的格式作为格式进行转换,但是在Oracle中会引起错误:“ORA 01810 格式代码出现两次”。
如:select to_date('2005-01-01 13:14:20','yyyy-MM-dd HH24:mm:ss') from dual;
原因是SQL中不区分大小写,MM和mm被认为是相同的格式代码,所以Oracle的SQL采用了mi代替分钟。
select to_date('2005-01-01 13:14:20','yyyy-MM-dd HH24:mi:ss') from dual;
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics