星期三, 十一月 24, 2010

如何遍历一个LIST 数组。

在List中vector其实本质上就是一个一维的数组。所以数组函数也是可以用于vector的

简单代码如下,构造一个List数组,然后遍历之。

(defvar alls)
(setf alls (vector '(10 12 14 20 22 26) '(03 05 06 07 11 12)))
(loop for i from 1 to (array-total-size alls)
do(loop for h from 1 to (list-length (svref alls (1- i)))
do(format t "~d," (nth (1- h) (svref alls (1- i))))
)
(format t "~%")
)
效果如图:





星期四, 十一月 11, 2010

MYSQL text column insert into UTF-8 .

注意:
http://dev.mysql.com/doc/refman/5.0/en/blob.html
text is  nonbinary strings is character strings . They have a character set, and values are sorted and compared based on the collation of the character set.

同varchar的行为不同。
table people字段chinese_desc为如下类型
CHINESE_DESC   text          utf8_unicode_ci

所以使用Java查询和插入 UTF-8字段插入汉字需要encoding 为 iso-8859-1
插入代码:
String SQL="update people set chinese_desc='\u9802\u7d44\u5408\u88fd\u9020' where ENG_desc='DJZHZZ' ;";//\u9802\u7d44\u5408\u88fd\u9020
String UTF8=new String(SQL.getBytes("UTF-8"),"ISO-8859-1");
PreparedStatement stmt=conn.prepareStatement("set names latin1");
stmt.execute(UTF8);

读取:

        String value =rset.getString("chinese_desc");   
        String value4 = new String(value.getBytes("ISO-8859-1"),"UTF-8");
      System.out.println(value4+"........");