在路上 ……

Linux系统运维与架构

今天极度郁闷,浪费了一下午的时间在apache和resin的整合上。写个备忘,希望下次不会再如此浪费时间。

首先apache和resin整合是有版本匹配问题的,比如apache2.0.的只能和resin3.0.版的整合。原来服务器上装的是resin3.1.18,死活和apache整合不上,后来google了一把,才发现有前辈写过一篇关于这个问题的文章。多谢前辈啊。

其次是应用部署的问题,整合好后,更新了一次应用,结果,就直接把jsp源码输出出来了。查看resin日志,查看apache日志,查看caucho status,一切都正常,就是输出源码。想到可能是新更新的文件没被编译,于是把work目录也删除了,重启了N次应用,依然无果。仔细又仔细的一遍遍查看配置文件,没发现任何错误。

无奈之下,试着把整个应用删除了,重新写了个极其简单的jsp布上去,居然OK了。我这叫一个郁闷啊,彻底无语。于是重新把应用部署了一次,这次终于正常了。

总结:这种版本问题,没办法,只能自己多试验或者多参考前辈的经验。应用更新出源码的问题,着实无奈。不知道resin是如何来实现的。当确信一切都没问题时,最好的办法就是一切从头开始。


作者:丁原 | 【转载时请务必以超链接形式标明文章原始出处和作者信息及本声明】
地址:http://rdc.taobao.com/blog/dba/html/234_mysql_date_func.html

通常我们会有一些时间的转换需求,比如要统计某个时间段的收入,比如要截取某个时间的年份,比如要根据某个日期推算出是星期几等个,这些都可以通过Mysql自带的时间函数很容易实现。因为我对Mysql的函数还不熟,而通常又会调用这些时间函数,这边稍加总结以便查询。
–返回当前时间

mysql> select now(),date(now()),sysdate();
+---------------------+-------------+---------------------+
| now()               | date(now()) | sysdate()           |
+---------------------+-------------+---------------------+
| 2008-12-02 10:11:36 | 2008-12-02  | 2008-12-02 10:11:36 |
+---------------------+-------------+---------------------+
1 row in set (0.00 sec)
mysql> select curdate(),curdate()+0,curtime(),curtime()+0;       
+---------------------+-------------+---------------------+
| curdate()  | curdate()+0 | curtime() | curtime()+0   |
+---------------------+-------------+---------------------+
| 2008-12-02 | 20081202    | 10:00:33  | 100033.000000 |
+---------------------+-------------+---------------------+

–返回日期当月最后一天

mysql> select last_day('2008-12-02');
+------------------------+
| last_day('2008-12-02') |
+------------------------+
| 2008-12-31             |
+------------------------+
1 row in set (0.00 sec)

–返回日期的星期几

mysql> select dayname('2008-12-02'),dayofweek('2008-12-02');
+-----------------------+-------------------------+
| dayname('2008-12-02') | dayofweek('2008-12-02') |
+-----------------------+-------------------------+
| tuesday               |                       3 |
+-----------------------+-------------------------+
1 row in set (0.00 sec)

–返回日期的年,月,日

mysql> select month('2008-12-02'),year('2008-12-02'),day('2008-12-02');
+---------------------+--------------------+-------------------+
| month('2008-12-02') | year('2008-12-02') | day('2008-12-02') |
+---------------------+--------------------+-------------------+
|                  12 |               2008 |                 2 |
+---------------------+--------------------+-------------------+
1 row in set (0.00 sec)

–返回日期的小时,分,秒

mysql> select hour('10:05:03'),minute('10:05:03'),second('10:05:03');       
+------------------+--------------------+--------------------+
| hour('10:05:03') | minute('10:05:03') | second('10:05:03') |
+------------------+--------------------+--------------------+
|               10 |                  5 |                  3 |
+------------------+--------------------+--------------------+
1 row in set (0.00 sec)

1.subdate(d,t):起始时间加上一段时间(year,month,day…)

mysql> select date_add('1998-01-02', interval 31 day),adddate('1998-01-02', 31);      
+-----------------------------------------+---------------------------+
| date_add('1998-01-02', interval 31 day) | adddate('1998-01-02', 31) |
+-----------------------------------------+---------------------------+
| 1998-02-02                              | 1998-02-02                |
+-----------------------------------------+---------------------------+
1 row in set (0.00 sec)
mysql> select date_add('1998-01-02',interval 2 year);
+-----------------------------------------------------+
| date_add('1998-01-02', interval 2 year) 
+-----------------------------------------------------+
| 2000-01-02                                 
+-----------------------------------------------------+
1 row in set (0.00 sec)
mysql> select date_add('1998-01-02', interval 2 hour);
+-----------------------------------------------------+
| date_add('1998-01-02', interval 2 hour) 
+-----------------------------------------------------+
| 1998-01-02 02:00:00                    
+-----------------------------------------------------+
1 row in set (0.00 sec)

2.subdate(d,t):起始时间减去一段时间

mysql> select subdate('1998-01-02', interval 31 day),subdate('1998-01-02', 31);
+----------------------------------------+---------------------------+
| subdate('1998-01-02', interval 31 day) | subdate('1998-01-02', 31) |
+----------------------------------------+---------------------------+
| 1997-12-02                             | 1997-12-02                |
+----------------------------------------+---------------------------+
1 row in set (0.00 sec)

3.addtime(d,t):起始时间d加入时间t

mysql> select addtime('1997-12-31 23:59:50','00:00:05'), addtime('23:59:50','00:00:05') ;
+-------------------------------------------+--------------------------------+
| addtime('1997-12-31 23:59:50','00:00:05') | addtime('23:59:50','00:00:05') |
+-------------------------------------------+--------------------------------+
| 1997-12-31 23:59:55                       | 23:59:55                       |
+-------------------------------------------+--------------------------------+
1 row in set (0.00 sec)

4.subtime(d,t):起始时间d减去时间t

mysql> select subtime('1997-12-31 23:59:50','00:00:05'), subtime('23:59:50','00:00:05');     
+-------------------------------------------+--------------------------------+
| subtime('1997-12-31 23:59:50','00:00:05') | subtime('23:59:50','00:00:05') |
+-------------------------------------------+--------------------------------+
| 1997-12-31 23:59:45                       | 23:59:45                       |
+-------------------------------------------+--------------------------------+
1 row in set (0.00 sec)

5.datediff(d1,d2):返回起始时间d1和结束时间d2之间的天数

mysql> select datediff('1997-12-31 23:59:59','1997-12-30');
+----------------------------------------------+
| datediff('1997-12-31 23:59:59','1997-12-30') |
+----------------------------------------------+
|                                            1 |
+----------------------------------------------+
1 row in set (0.00 sec)

6.date_format(date,format):根据format字符串显示date值的格式

mysql> select date_format('2008-12-02 22:23:00', '%y %m %m %h:%i:%s');
+---------------------------------------------------------+
| date_format('2008-12-02 22:23:00', '%y %m %m %h:%i:%s') |
+---------------------------------------------------------+
| 2008 12 12 22:23:00                                     |
+---------------------------------------------------------+
1 row in set (0.00 sec)

7.str_to_date(str,format) 字符串转化为时间

mysql> select str_to_date('04/31/2004', '%m/%d/%y %h:%i:s');
+-----------------------------------------------+
| str_to_date('04/31/2004', '%m/%d/%y %h:%i:s') |
+-----------------------------------------------+
| 2004-04-31 00:00:00                           |
+-----------------------------------------------+
1 row in set (0.00 sec)

8.timestamp(expr) , timestamp(expr,expr2) :
对于一个单参数,该函数将日期或日期时间表达式 expr 作为日期时间值返回.对于两个参数, 它将时间表达式 expr2添加到日期或日期时间表达式 expr 中,将theresult作为日期时间值返回

mysql> select timestamp('2003-12-31'), timestamp('2003-12-31 12:00:00','12:00:00');
+-------------------------+---------------------------------------------+
| timestamp('2003-12-31') | timestamp('2003-12-31 12:00:00','12:00:00') |
+-------------------------+---------------------------------------------+
| 2003-12-31 00:00:00     | 2004-01-01 00:00:00                         |
+-------------------------+---------------------------------------------+
1 row in set (0.00 sec)

9.取当天0点0分,下一天0点0分

mysql> select timestamp(date(sysdate())),timestamp(adddate(date(sysdate()),1));      
+----------------------------+---------------------------------------+
| timestamp(date(sysdate())) | timestamp(adddate(date(sysdate()),1)) |
+----------------------------+---------------------------------------+
| 2008-12-02 00:00:00        | 2008-12-03 00:00:00                   |
+----------------------------+---------------------------------------+
1 row in set (0.00 sec)

转帖自http://www.blogjava.net/hilor/articles/164814.html

在使用MySql 时, 数据库中的字段类型是timestamp的,默认为0000-00-00, 会发生异常:

java.sql.SQLException:   Value   '0000-00-00 '   can   not   be   represented   as   java.sql.Timestamp 

解决办法:

给jdbc url加上 zeroDateTimeBehavior参数:

datasource.url=jdbc:mysql://localhost:3306/testdb?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true 

zeroDateTimeBehavior=round是为了指定MySql中的DateTime字段默认值查询时的处理方式;默认是抛出异常,

对于值为0000-00-00 00:00:00(默认值)的纪录,如下两种配置,会返回不同的结果:

zeroDateTimeBehavior=round   0001-01-01   00:00:00.0 

zeroDateTimeBehavior=convertToNull   null

Extmail系统,webmail登陆后查看收件箱,提示

Can't call method "tie" on an undefined value at /usr/local/www/extmail/libs/Ext/DB.pm line 90.

可能是由于目录的缓存数据文件有问题造成的。删除该用户maildir目录下的extmail-curcache.db文件即可。


网上看了N种方法,但是一一试验过,都无效或临时有效

最终找到一个终极解决办法,比较好使。

修改文件描述符限制(root用户下):

#vi  /etc/security/limits.conf在最下面添加一行
*               -       nofile          65530

这里我改了个比较大的数65530,可以自己根据实际需要改为合适的值。


Typecho 强力驱动