<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:wfw="http://wellformedweb.org/CommentAPI/">
  <channel>
    <title><![CDATA[LalfaShi'Blog]]></title> 
    <link>http://blog.lalfa.com/</link> 
    <description><![CDATA[　猝然临之而不惊，无故加之而不怒]]></description> 
    <language>GBK</language> 
    <copyright><![CDATA[Copyright 2009, LalfaShi'Blog]]></copyright> 
    <webMaster><![CDATA[ealpha@citiz.net (LALFASHI)]]></webMaster> 
    <generator>LBS v2.0.310</generator> 
    <pubDate>Tue, 06 Jan 2009 23:35:59 +0800</pubDate> 
    <ttl>60</ttl>
  
    <item>
      <title><![CDATA[解决 c3p0 和 MySQL 集成情况下，连接长时间闲置后重新使用时报错的问题]]></title> 
      <link><![CDATA[http://blog.lalfa.com/article.asp?id=313]]></link> 
      <category><![CDATA[Database]]></category> 
      <author><![CDATA[LALFASHI <null@null.com>]]></author> 
      <pubDate>Tue, 06 Jan 2009 11:20:21 +0800</pubDate> 
      <description><![CDATA[MySQL 的默认设置下，当一个连接的空闲时间超过8小时后，MySQL 就会断开该连接，而 c3p0 连接池则以为该被断开的连接依然有效。在这种情况下，如果客户端代码向 c3p0 连接池请求连接的话，连接池就会把已经失效的连接返回给客户端，客户端在使用该失效连接的时候即抛出异常。<br />解决这个问题的办法有三种：<br />1. 增加 MySQL 的 wait_timeout 属性的值。<br />修改 /etc/mysql/my.cnf 文件，在 [mysqld] 节中设置：<div class="code"># Set a connection to wait 8 hours in idle status.<br />wait_timeout = 86400</div><br />2. 减少连接池内连接的生存周期，使之小于上一项中所设置的 wait_timeout 的值。<br />修改 c3p0 的配置文件，设置：<div class="code"># How long to keep unused connections around(in seconds)<br /># Note: MySQL times out idle connections after 8 hours(28,800 seconds)<br /># so ensure this value is below MySQL idle timeout<br />cpool.maxIdleTime=25200</div>]]></description>
      <wfw:commentRss><![CDATA[http://blog.lalfa.com/feed.asp?q=comment&id=313]]></wfw:commentRss>
    </item>
      
    <item>
      <title><![CDATA[Sending Email Using Apache Log4J]]></title> 
      <link><![CDATA[http://blog.lalfa.com/article.asp?id=312]]></link> 
      <category><![CDATA[Ant/Maven/Junit]]></category> 
      <author><![CDATA[LALFASHI <null@null.com>]]></author> 
      <pubDate>Mon, 22 Dec 2008 09:32:14 +0800</pubDate> 
      <description><![CDATA[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.<br />SMTPAppender is the class that is responsible for performing email operation, it internally uses Java Mail API for sending mails.<br />This article will show ]]></description>
      <wfw:commentRss><![CDATA[http://blog.lalfa.com/feed.asp?q=comment&id=312]]></wfw:commentRss>
    </item>
      
    <item>
      <title><![CDATA[MYSQL 5.1 event_scheduler]]></title> 
      <link><![CDATA[http://blog.lalfa.com/article.asp?id=311]]></link> 
      <category><![CDATA[Database]]></category> 
      <author><![CDATA[LALFASHI <null@null.com>]]></author> 
      <pubDate>Fri, 28 Nov 2008 13:49:45 +0800</pubDate> 
      <description><![CDATA[my.ini or my.cnf 中的<br />[mysqld]<br />添加 event_scheduler=ON<br /><br />创建事件(CREATE EVENT)<br />先来看一下它的语法：<div class="code">CREATE EVENT [IF NOT EXISTS] event_name<br />&nbsp;&nbsp;&nbsp;&nbsp;ON SCHEDULE schedule<br />&nbsp;&nbsp;&nbsp;&nbsp;[ON COMPLETION [NOT] PRESERVE]<br />&nbsp;&nbsp;&nbsp;&nbsp;[ENABLE | DISABLE]<br />&nbsp;&nbsp;&nbsp;&nbsp;[COMMENT &#39;comment&#39;]<br />&nbsp;&nbsp;&nbsp;&nbsp;DO sql_statement;<br />&nbsp;<br />schedule:<br />&nbsp;&nbsp;&nbsp;&nbsp;AT TIMESTAMP [+ INTERVAL INTERVAL]<br />&nbsp;&nbsp;| EVERY INTERVAL [STARTS TIMESTAMP] [ENDS TIMESTAMP]<br />&nbsp;<br />INTERVAL:<br />&nbsp;&nbsp;&nbsp;&nbsp;quantity {YEAR | QUARTER | MONTH | DAY | HOUR | MINUTE |<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WEEK | SECOND | YEAR_MONTH | DAY_HOUR | DAY_MINUTE |<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DAY_SECOND | HOUR_MINUTE | HOUR_SECOND | MINUTE_SECOND}<br /></div><br />1) 首先来看一个简单的例子来演示每秒插入一条记录到数据表<br />&#91;code]&#91;/code]]]></description>
      <wfw:commentRss><![CDATA[http://blog.lalfa.com/feed.asp?q=comment&id=311]]></wfw:commentRss>
    </item>
      
    <item>
      <title><![CDATA[Export CSV directly from MySQL]]></title> 
      <link><![CDATA[http://blog.lalfa.com/article.asp?id=310]]></link> 
      <category><![CDATA[Database]]></category> 
      <author><![CDATA[LALFASHI <null@null.com>]]></author> 
      <pubDate>Fri, 28 Nov 2008 11:20:05 +0800</pubDate> 
      <description><![CDATA[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!<br /><br />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:<br /><div class="code">SELECT id, name, email INTO OUTFILE &#39;/tmp/result.csv&#39;<br />FIELDS TERMINATED BY &#39;,&#39; OPTIONALLY ENCLOSED BY &#39;&quot;&#39;<br />LINES TERMINATED BY &#39;\n&#39;<br />FROM users WHERE 1</div><br />Well, if you know MySQL, you’ll know how to customize ]]></description>
      <wfw:commentRss><![CDATA[http://blog.lalfa.com/feed.asp?q=comment&id=310]]></wfw:commentRss>
    </item>
      
    <item>
      <title><![CDATA[MYSQL 5.1.29 查询 datatime &lt; &#39;2008-11-00&#39; 导致崩溃]]></title> 
      <link><![CDATA[http://blog.lalfa.com/article.asp?id=309]]></link> 
      <category><![CDATA[Database]]></category> 
      <author><![CDATA[LALFASHI <null@null.com>]]></author> 
      <pubDate>Tue, 25 Nov 2008 10:09:55 +0800</pubDate> 
      <description><![CDATA[--------------------<br /><br /><span style="color:Red">update 正式版的5.1.30 还有此问题 </span><br />---------------------<br />为了使用mySQL的表分区功能，系统升级数据库到 5.1.29 启用表分区；<br /><br />可是有一条查询语句，总是导致数据库崩溃。<br /><br />详见：<a href="http://bugs.mysql.com/bug.php?id=40972" title="http://bugs.mysql.com/bug.php?id=40972" target="_blank">http://bugs.mysql.com/bug.php?id=40972</a><br /><br />081124 18:23:41 - mysqld got signal 11 ;<br />This could be because you hit a bug. It is also possible that this binary<br />or one of the libraries it was linked against is corrupt, improperly built,<br />or misconfigured. This error can also be caused by malfunctioning hardware.<br />We will try our best to scrape up some info that will hopefully help diagnose<br />the problem, but since we have already crashed, something is definitely wrong<br />]]></description>
      <wfw:commentRss><![CDATA[http://blog.lalfa.com/feed.asp?q=comment&id=309]]></wfw:commentRss>
    </item>
      
    <item>
      <title><![CDATA[windows 下  memcached 配置和java client测试]]></title> 
      <link><![CDATA[http://blog.lalfa.com/article.asp?id=308]]></link> 
      <category><![CDATA[软件工程]]></category> 
      <author><![CDATA[LALFASHI <null@null.com>]]></author> 
      <pubDate>Tue, 18 Nov 2008 20:14:29 +0800</pubDate> 
      <description><![CDATA[明天继续]]></description>
      <wfw:commentRss><![CDATA[http://blog.lalfa.com/feed.asp?q=comment&id=308]]></wfw:commentRss>
    </item>
      
    <item>
      <title><![CDATA[windows 下 Nginx + tomcat 负载均衡配置]]></title> 
      <link><![CDATA[http://blog.lalfa.com/article.asp?id=307]]></link> 
      <category><![CDATA[软件工程]]></category> 
      <author><![CDATA[LALFASHI <null@null.com>]]></author> 
      <pubDate>Tue, 18 Nov 2008 20:05:08 +0800</pubDate> 
      <description><![CDATA[Nginx 已经是目前公认的效率很高的代理服务，同时可以用来做负载均衡。<br /><br />由于项目目前只有一台centOS的服务器，无法用来测试，所以打算找下Nginx windows下版本；<br /><br /><a href="http://www.kevinworthington.com/nginx/win32/" title="http://www.kevinworthington.com/nginx/win32/" target="_blank">http://www.kevinworthington.com/nginx/win32/</a><br /><br />以上为win32的版本<br /><br />用户访问 sp.imichat.com 均衡到 10.10.10.181:8080;  10.10.10.181:8081;   10.10.10.181:8082;  这3台服务器<br /><br />配置Nginx的nginx.conf<br /><br />http {}增加如下内容<br /> <div class="code">&nbsp;&nbsp;&nbsp;&nbsp;upstream sp.imichat.com { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server 10.10.10.181:8080; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server 10.10.10.181:8081; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server 10.10.10.181:8082; <br />&nbsp;&nbsp;&nbsp;&nbsp;}</div><br />server {} 修改异侠信息：<br /><div class="code">&nbsp;listen       80;<br />&nbsp;server_name  sp.imichat.com;<br /><br />&nbsp;#charset koi8-r;<br /><br />&nbsp;#access_log  logs/host_access_log  main;</div>]]></description>
      <wfw:commentRss><![CDATA[http://blog.lalfa.com/feed.asp?q=comment&id=307]]></wfw:commentRss>
    </item>
      
    <item>
      <title><![CDATA[Using MySql 5.0 stored procedures with MySQLdb]]></title> 
      <link><![CDATA[http://blog.lalfa.com/article.asp?id=306]]></link> 
      <category><![CDATA[Python]]></category> 
      <author><![CDATA[LALFASHI <null@null.com>]]></author> 
      <pubDate>Sat, 06 Sep 2008 17:24:41 +0800</pubDate> 
      <description><![CDATA[When I wanted to try out MySQL 5.0 stored procedures I didn&#39;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.<br /><br />Why use stored procedures in the first place? While stored procedures give a you a performance boost (I have not benchmarked so I can&#39;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&#39;t break the interface. There ]]></description>
      <wfw:commentRss><![CDATA[http://blog.lalfa.com/feed.asp?q=comment&id=306]]></wfw:commentRss>
    </item>
      
    <item>
      <title><![CDATA[Django肆意使用中文]]></title> 
      <link><![CDATA[http://blog.lalfa.com/article.asp?id=305]]></link> 
      <category><![CDATA[Python]]></category> 
      <author><![CDATA[LALFASHI <null@null.com>]]></author> 
      <pubDate>Thu, 31 Jul 2008 11:40:06 +0800</pubDate> 
      <description><![CDATA[刚开始遇到了些问题，后来发现，用manage.py生成的model.py默认是ascii的，需要做两道加工：<br />1  在文件首行加入<br /># -*- coding: utf-8 -*-<br /><br />2<br />用UltraEdit的 文件/转换/ASCII 转 UTF8    功能将文件转换为UTF8存盘<br /><br />这样就可以肆意使用中文了。]]></description>
      <wfw:commentRss><![CDATA[http://blog.lalfa.com/feed.asp?q=comment&id=305]]></wfw:commentRss>
    </item>
      
    <item>
      <title><![CDATA[MySQLdb for Python使用指南/Python的数据库操作]]></title> 
      <link><![CDATA[http://blog.lalfa.com/article.asp?id=304]]></link> 
      <category><![CDATA[Python]]></category> 
      <author><![CDATA[LALFASHI <null@null.com>]]></author> 
      <pubDate>Thu, 24 Jul 2008 21:33:43 +0800</pubDate> 
      <description><![CDATA[网站就是要和数据库进行交互,否则什么都不用做了...今天我们来看一个叫MySQLdb的库,这个用来和MySQL数据库进行交互.<br />可以从这里获得这个库<br /><a href="http://sourceforge.net/projects/mysql-python" title="http://sourceforge.net/projects/mysql-python" target="_blank">http://sourceforge.net/projects/mysql-python</a><br />如果你不确定你的python环境里有没有这个库,那就打开python shell,输入 import MySQLdb,如果返回错误信息,那就表示你的机器上没有,赶紧去下载一个.我的机器是win xp,所以我下载了win环境下的exe那个,直接双击完成安装.<br /><br />在介绍具体的操作前,先花点时间来说说一个程序怎么和数据库进行交互<br />1.和数据库建立连接<br />2.执行sql语句,接收返回值<br />3.关闭数据库连接<br />使用MySQLdb也要遵循上面的几步.让我们一步步的进行.<br /><br /><b>0.引入MySQLdb库</b><br />import MySQLdb<br /><br /><b>1.和数据库建立连接</b><br />conn=MySQLdb.connect(host=&quot;localhost&quot;,user=&quot;root&quot;,passwd=&quot;sa&quot;,db=&quot;mytable&quot;)<br />提供的connect方法用来和数据库建立连接,接收数个参数,返回连接对象.<br /><br />比较常用的参数包括<br />host:数据库主机名.默认是用本地主机.<br />user:数据库登陆名.默认是当前用户.<br />passwd:数据库登陆的秘密.默认为空.<br />]]></description>
      <wfw:commentRss><![CDATA[http://blog.lalfa.com/feed.asp?q=comment&id=304]]></wfw:commentRss>
    </item>
      
  </channel>
</rss>
