2008-12-10 16:11:07


最近饱受北京(010)的据称是"中国收藏家协会"电话骚扰,电话诈骗,所有的号码如下,持续添加中。。。
010-59151515;010-59151616;010-86763606;010-81625825;010-52094517;010-58825800
浏览模式: 普通 | 列表
MySQL 的默认设置下,当一个连接的空闲时间超过8小时后,MySQL 就会断开该连接,而 c3p0 连接池则以为该被断开的连接依然有效。在这种情况下,如果客户端代码向 c3p0 连接池请求连接的话,连接池就会把已经失效的连接返回给客户端,客户端在使用该失效连接的时候即抛出异常。
解决这个问题的办法有三种:
1. 增加 MySQL 的 wait_timeout 属性的值。
修改 /etc/mysql/my.cnf 文件,在 [mysqld] 节中设置:
# Set a connection to wait 8 hours in idle status.
wait_timeout = 86400

2. 减少连接池内连接的生存周期,使之小于上一项中所设置的 wait_timeout 的值。
修改 c3p0 的配置文件,设置:
# How long to keep unused connections around(in seconds)
# Note: MySQL times out idle connections after 8 hours(28,800 seconds)
# so ensure this value is below MySQL idle timeout
cpool.maxIdleTime=25200
...

阅读全文...

Sending Email Using Apache Log4J

[ 2008-12-22 09:32:14 | 作者: LALFASHI ]
he Log4J is being widely used for performing logging in Java Application, while doing logging we also encounter errors and we write log.error() statements. This statement indicates that an serious error has occurred while executing the Java code. In a critical application checking for this message at runtime is a tedious job but thanks to Apache Log4J, they provide an provision for sending emails whenever an error statement is executed.
SMTPAppender is the class that is responsible for performing email operation, it internally uses Java Mail API for sending mails.
This article will show ...

阅读全文...

MYSQL 5.1 event_scheduler

[ 2008-11-28 13:49:45 | 作者: LALFASHI ]
my.ini or my.cnf 中的
[mysqld]
添加 event_scheduler=ON

创建事件(CREATE EVENT)
先来看一下它的语法:
CREATE EVENT [IF NOT EXISTS] event_name
    ON SCHEDULE schedule
    [ON COMPLETION [NOT] PRESERVE]
    [ENABLE | DISABLE]
    [COMMENT 'comment']
    DO sql_statement;
 
schedule:
    AT TIMESTAMP [+ INTERVAL INTERVAL]
  | EVERY INTERVAL [STARTS TIMESTAMP] [ENDS TIMESTAMP]
 
INTERVAL:
    quantity {YEAR | QUARTER | MONTH | DAY | HOUR | MINUTE |
              WEEK | SECOND | YEAR_MONTH | DAY_HOUR | DAY_MINUTE |
              DAY_SECOND | HOUR_MINUTE | HOUR_SECOND | MINUTE_SECOND}

1) 首先来看一个简单的例子来演示每秒插入一条记录到数据表
[code][/code]...

阅读全文...

Export CSV directly from MySQL

[ 2008-11-28 11:20:05 | 作者: LALFASHI ]
How ofter were you asked by a client for a CSV (or excel) file with data from their app? I get asked that question quite often, so I wanted make the process as easy as possible. And guess what? You can create CSV files directly from MySQL with just one query!

Let’s say you want to export the id, name and email fields from your users table to a CSV file. Here is your code:
SELECT id, name, email INTO OUTFILE '/tmp/result.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM users WHERE 1

Well, if you know MySQL, you’ll know how to customize ...

阅读全文...
--------------------

update 正式版的5.1.30 还有此问题
---------------------
为了使用mySQL的表分区功能,系统升级数据库到 5.1.29 启用表分区;

可是有一条查询语句,总是导致数据库崩溃。

详见:http://bugs.mysql.com/bug.php?id=40972

081124 18:23:41 - mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
...

阅读全文...
明天继续

windows 下 Nginx + tomcat 负载均衡配置

[ 2008-11-18 20:05:08 | 作者: LALFASHI ]
Nginx 已经是目前公认的效率很高的代理服务,同时可以用来做负载均衡。

由于项目目前只有一台centOS的服务器,无法用来测试,所以打算找下Nginx windows下版本;

http://www.kevinworthington.com/nginx/win32/

以上为win32的版本

用户访问 sp.imichat.com 均衡到 10.10.10.181:8080; 10.10.10.181:8081; 10.10.10.181:8082; 这3台服务器

配置Nginx的nginx.conf

http {}增加如下内容
    upstream sp.imichat.com {
      server 10.10.10.181:8080;
      server 10.10.10.181:8081;
      server 10.10.10.181:8082;
    }

server {} 修改异侠信息:
 listen 80;
 server_name sp.imichat.com;

 #charset koi8-r;

 #access_log logs/host_access_log main;
...

阅读全文...
When I wanted to try out MySQL 5.0 stored procedures I didn't find too much on the web. This was a few months ago and there may be some better tutorials out there now but I figured I would share some of my tricks.

Why use stored procedures in the first place? While stored procedures give a you a performance boost (I have not benchmarked so I can't say how much) the argument I usually use when making the case for using stored procedures is abstraction. One can make changes to a stored procedure and not have to touch the calling code just as long as you don't break the interface. There ...

阅读全文...