<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Duran's technical life
    踏踏實實學(xué)技術(shù),認(rèn)認(rèn)真真做研究。

    2005年8月9日

    從MySql5中運行本地腳本創(chuàng)建數(shù)據(jù)庫,當(dāng)插入中文字段時發(fā)生“data too long for column”錯誤。上網(wǎng)一查,發(fā)現(xiàn)多字節(jié)用戶大都碰到了這種情況。google搜索網(wǎng)上的解決方法大都是要將數(shù)據(jù)庫的編碼方式為GBK或UTF8,可我在安裝MySql時就選擇了UTF8格式。原來錯誤原因是本地的腳本文件不是UTF8編碼的,用記事本或UltraEdit將編碼轉(zhuǎn)為UTF8后問題解決。再次強調(diào),JSP頁面,數(shù)據(jù)庫聯(lián)接接方式,數(shù)據(jù)庫創(chuàng)建,…,都須一致使用UTF8編碼!

    BTW,MySql最近借著Web2.0的浪潮風(fēng)頭很勁啊,techn orati(好像這幾天被GFW filter了),flickr,del.icio.us等一批網(wǎng)站都是用了MySql。MySql還專門在首頁開了一大塊來炫耀。
    posted @ 2006-07-14 19:12 Duran's technical life 閱讀(9195) | 評論 (4)編輯 收藏
     
    Installed JDK6 (Mustang) beta and Eclipse3.2 . As Sun promised , Swing library, especially the?WindowsLookAndFeel feels much better. It’s hard to tell the difference between a Swing drawn window and a WINXP native window. Developing Java desktop applications is worth considering. Mattise, a free easy-to-use WYSIWYG Swing UI designer, is the only reason for many to use the tedious NetBeans. Recently, Genuitec provided Matisse4Eclipse, which is?an implementation of Matisse that integrates its functionality into MyEclipse Workbench to enable the easy creation of Swing applications with Eclipse. So the only reason to use NetBeans has gone.
    posted @ 2006-07-13 22:17 Duran's technical life 閱讀(1049) | 評論 (0)編輯 收藏
     
    去年7月決定考研后暫停了對Java技術(shù)的學(xué)習(xí)。錄研上后專心開發(fā)導(dǎo)師負(fù)責(zé)的項目,到4月份從深圳出差回來后又忙著做畢設(shè)。快一年的時間沒跟新這,幾乎都要abandon了。百度剛開放了百度空間的注冊,不過看起來不咋的。選國外的BSP會面臨隨時偉大的GFW過濾掉的后果。總的來說,BlogJava還是很適合post技術(shù)方面的東西,優(yōu)點是流量大,被google收錄快;缺點就是沒有trackback。前幾天下午跑到圖書館看了看上半年的程序員,新鮮玩意并不多。SOA,這個被預(yù)測為06年最熱點的技術(shù),并沒有什么有趣的文章,或許這個名詞還是沒有個明確的含義和應(yīng)用。在學(xué)校里,IBM的SOA大賽倒是舉辦的風(fēng)風(fēng)火火。JavaEE5,JDK 6的發(fā)布還是給Java界帶來不少有趣又實用的新東東,比如annotation,persistence API和script supporting。得跟上技術(shù)前進的步伐了,以后技術(shù)的筆記還是發(fā)這里,平日的雜想就寫在我的MSN space上。
    posted @ 2006-07-13 22:14 Duran's technical life 閱讀(335) | 評論 (0)編輯 收藏
     

    @title [筆記]事務(wù)處理

    #1 Transaction Propagation Behavior
    Required:Excute within a current tx, create a new one if none exists.
    Supports: Excute within a current tx, execute without a tx if none exsits.
    Mandatory: Excute within a current tx, throw an exception if none exists.
    Requires New: Create a new tx and excute within the tx, suspend the current tx if one exists.
    Not Supported: Excute without a tx, suspend the current tx if none exsits.
    Never: Excute without a tx, throw an exception if a tx exsits.

    #2 Transaction Isolation Level[1]
    #2.1 Concurrent Problem
    Dirty Reads: 臟讀(臟數(shù)據(jù)指已更新,還沒提交的數(shù)據(jù))。事務(wù)T1讀取到事務(wù)T2中的臟數(shù)據(jù)。

    Unrepeatable Reads: 不可重復(fù)讀。事務(wù)T1檢索到某行后,事務(wù)T2更新并提交了該行,若事務(wù)T2再次檢索該行,則會看到不一樣的結(jié)果。

    Phantom Reads: 虛讀。事務(wù)T1檢索到符合某條件的行集后,事務(wù)T2插入并提交了滿足該條件的新行,若事務(wù)T2再次按該條件檢索,則會看到以前不存在的行“Phantom”。

    #2.2 Isolation Level
    +---------------+-------+------------------+-----------+
    |Isolation Level|Phantom|Unrepeatable Reads|Dirty Reads|
    +---------------+-------+------------------+-----------+
    |Read Uncommited|   Y   |         Y        |     Y     |
    +---------------+-------+------------------+-----------+
    |Read Commited  |   Y   |         Y        |     N     |
    +---------------+-------+------------------+-----------+
    |Repeatable Read|   Y   |         N        |     N     |
    +---------------+-------+------------------+-----------+
    |Serializable   |   N   |         N        |     N     |
    +---------------+-------+------------------+-----------+

    #3 Timeout

    #4 ReadOnly Transaction
    只讀事務(wù)保證了多條查詢SQL的在事務(wù)級別的讀一致性。JDBC和數(shù)據(jù)庫會對只讀事務(wù)做一些優(yōu)化。

    [1] C.J.Date, An Introduction to Database Systems 7th.

    posted @ 2005-09-09 13:09 Duran's technical life 閱讀(725) | 評論 (1)編輯 收藏
     

    iteration::two Cairngorm 0.99 開發(fā)指南
    @author sakis
    @version 0.1

    #0
    MXML優(yōu)點:使用方便,XML代碼簡潔易懂
    缺點:事件、函數(shù)、界面描混在一起。程序規(guī)模大了難于開發(fā)維護。

    #1
    Cairngorm框架是iterationtwo推出的號稱基于JEE Best Practice的Flex程序開發(fā)的light-weight framework。(恩,light-weight這個詞還真是流行呢)。目前最新版本為0.99。

    Cairngorm的結(jié)構(gòu)如下:
    org
    └─nevis
        └─cairngorm
            ├─application
            │      CairngormApplication.as
            │
            ├─business
            │      Responder.as
            │      ServiceLocator.as
            │
            ├─commands
            │      Command.as
            │      SequenceCommand.as
            │
            ├─control
            │      Event.as
            │      EventBroadcaster.as
            │      FrontController.as
            │
            ├─model
            │      ModelLocator.as
            │
            ├─view
            │      ViewHelper.as
            │      ViewLocator.as
            │
            └─vo
                    ValueObject.as


    #2
    下面給大家簡單介紹Cairngorm的實現(xiàn)思路。

    #2.1
    Command/FrontController將Event與Viwe分離。
    FrontController實現(xiàn)Singleton模式(以下簡寫為SP)。所有自定義的Command在要在FrontController構(gòu)造函數(shù)中實例化并以關(guān)聯(lián)數(shù)組的方式注冊FrontController#addCommand(eventType:String, commandInstance:Command)。EventBroadcaster實現(xiàn)SP。Event類的結(jié)構(gòu)為{type:eventType, data:eventData}。我們通過EventBroadcaster#broadcastEvent(eventType:String, eventData:Object)發(fā)布Event。Event發(fā)布后,與eventType對應(yīng)的command instance執(zhí)行Command#execute(event:Event)。

    BTW:在Cairngorm的源碼中,eventType、commandName、eventName混用,我統(tǒng)一用eventType。

    #2.2
    ServiceLocator將Remote Service聲明與View分離。
    ServiceLocator實現(xiàn)SP。在Cairngorm的demo中,又通過Delegate對象解除Command/Responder和ServiceLocator之間的依賴。這個Delegate做的事情其實意義不大,就是調(diào)用ServiceLocator中的Method,設(shè)置莫個Responder為相應(yīng)遠(yuǎn)程方法的handler。個人覺得無謂地增加了代碼量,而且Delegate對象也沒實現(xiàn)SP,也就是說我們每次調(diào)用一次Remote Service中的Method,都要new一個Delegate對象,實在浪費。

    #2.3
    ViewLocator/ViewHelper將View(MXML)中夾雜的function與View分離。
    ViewHelper有點意思,當(dāng)一個ViewHelper在某個MXML頁面中聲明時,如<view:LoginViewHelper id="loginViewHelper" />。ViewHelper能自動取得所在MXML對象的引用,并通過ViewLocator#register(id, this:ViewHelper)將自身注冊到ViewLocator中。ViewLocator實現(xiàn)SP。借助ViewLocator/ViewHelper,我們就可以方便的調(diào)用不同MXML頁面中的方法。

    #2.4
    ModelLocator是一個marker interface,程序中Model可以放在某個ModelLocator方便調(diào)用。

    #2.5
    ValueObject也是一個marker interface, 基本不需要。

    #3
    Cairngorm.99給我們開發(fā)Flex程序提供了很不錯的架構(gòu)模式,M/V/C/Remote之間可以做到完全解構(gòu)。但在實際開發(fā)時沒有必要死扣,代碼結(jié)構(gòu)清晰有活力就好。

    posted @ 2005-09-07 21:49 Duran's technical life 閱讀(889) | 評論 (0)編輯 收藏
     

    Hibernate一對一關(guān)聯(lián)實用介紹

    #0
    書和文檔上寫的都不是特清楚的。自己記下來。

    #1 Using a PK association

    #1.1 POJO with XDolclet annotation
    public class Customer {
     /**
      * @return Returns the shoppingCart.
      * @hibernate.many-to-one cascade="delete" column="shopping_cart_id"
      *  unique="true" foreign-key="FK_SHOPPING_CART__CUSTOMER"
      */
     public ShoppingCart getShoppingCart() {
      return shoppingCart;
     }
    }

    public class ShoppingCart {
     /**
      * @return Returns the customer.
      * @hibernate.one-to-one property-ref="shoppingCart"
      */
     public Customer getCustomer() {
      return customer;
     }
    }

    property-ref="shoppingCart" 告訴Hibernate ShoppingCart#customer和Customer#shoppingCart是反向的關(guān)系。所以Hibernate知道如何從ShoppingCart#getCustomer中檢索到相應(yīng)的customer對象。取出某個Customer對象時,Hibernate會生成DEBUG SQL:324 - 3中的SQL語句。

    #1.2 HBM
    Customer.hbm.xml
    <many-to-one
        name="shoppingCart"
        class="ShoppingCart"
        cascade="delete"
        outer-join="auto"
        foreign-key="FK_SHOPPING_CART__CUSTOMER"
        column="shopping_cart_id"
    />

    ShoppingCart.hbm.xml
    <one-to-one
        name="customer"
        class="Customer"
        cascade="none"
        outer-join="auto"
        constrained="false"
        property-ref="shoppingCart"
    />

    #1.3 SCHEMA SQL
    create table CUSTOMER (
        ID bigint generated by default as identity (start with 1),
        SHOPPING_CART_ID bigint,
        primary key (ID)
    )

    create table SHOPPING_CART (
        ID bigint generated by default as identity (start with 1)
        primary key (ID)
    )

    alter table CUSTOMER
        add constraint FK_SHOPPING_CART__CUSTOMER
        foreign key (SHOPPING_CART_ID)
        references SHOPPING_CART

    #1.4 Query SQL
    DEBUG SQL:324 - 1
    select customer0_.ID as ID, customer0_.SHOPPING_CART_ID as SHOPPING2_3_, customer0_.USERNAME as USERNAME3_, customer0_.PWD as PWD3_
    from CUSTOMER customer0_
    where customer0_.USERNAME=? and customer0_.PWD=?

    DEBUG SQL:324 - 2
    select shoppingca0_.ID as ID0_, shoppingca0_.TOTAL as TOTAL8_0_
    from SHOPPING_CART shoppingca0_
    where shoppingca0_.ID=?

    DEBUG SQL:324 - 3
    select customer0_.ID as ID1_, customer0_.SHOPPING_CART_ID as SHOPPING2_3_1_, customer0_.USERNAME as USERNAME3_1_, customer0_.PWD as PWD3_1_, shoppingca1_.ID as ID0_, shoppingca1_.TOTAL as TOTAL8_0_
    from
     CUSTOMER customer0_
     left outer join
     SHOPPING_CART shoppingca1_
     on customer0_.SHOPPING_CART_ID=shoppingca1_.ID
    where customer0_.SHOPPING_CART_ID=?


    #2 Using a FK association

    #2.1 POJO with XDolclet annotation
    public class Customer {
     /**
      * @return Returns the shoppingCart.
      * @hibernate.one-to-one cascade="delete"
      */
     public ShoppingCart getShoppingCart() {
      return shoppingCart;
     }
    }

    public class ShoppingCart {
     /**
      * @return Returns the id.
      * @hibernate.id generator-class="foreign"
      * @hibernate.generator-param name="property" value="customer"
      */
     public Long getId() {
      return id();
     }

     /**
      * @return Returns the customer.
      * @hibernate.one-to-one constrained="true" foreign-key="FK_CUSTOMER__SHOPPING_CART"
      */
     public Customer getCustomer() {
      return customer;
     }
    }

    constrained="true" 告訴Hibernate ShoppingCart的PK還應(yīng)該是一個FK,這個FK引用Customer的PK。還需要多做一點工作,聲明ShoppingCart的PK生成策略是foreign,對應(yīng)ShoppingCart#customer。這和上面一句話不是一個意思嘛,F(xiàn)T~~

    #2.2 HBM
    Customer.hbm.xml
    <one-to-one
        name="shoppingCart"
        class="ShoppingCart"
        cascade="delete"
        outer-join="auto"
        constrained="false"
    />

    ShoppingCart.hbm.xml
    <id
        name="id"
        column="id"
        type="java.lang.Long"
    >
        <generator class="foreign">
     <param name="property">customer</param>
        </generator>
    </id>

    <one-to-one
        name="customer"
        class="Customer"
        cascade="none"
        outer-join="auto"
        constrained="true"
    />

    #2.3 SCHEMA SQL
    create table CUSTOMER (
        ID bigint generated by default as identity (start with 1),
        primary key (ID)
    )

    create table SHOPPING_CART (
        ID bigint not null,
        TOTAL integer,
        primary key (ID)
    )

    alter table SHOPPING_CART
        add constraint FK_CUSTOMER__SHOPPING_CART
        foreign key (ID)
        references CUSTOMER

    #2.4 Query SQL
    DEBUG SQL:324 -
    select customer0_.ID as ID, customer0_.USERNAME as USERNAME3_, customer0_.PWD as PWD3_
    from CUSTOMER customer0_
    where customer0_.USERNAME=? and customer0_.PWD=?

    DEBUG SQL:324 -
    select shoppingca0_.ID as ID0_, shoppingca0_.TOTAL as TOTAL8_0_
    from SHOPPING_CART shoppingca0_
    where shoppingca0_.ID=?

    這個“真正”的one-to-one的好處是少條關(guān)聯(lián)SQL語句,看到了嗎?

    posted @ 2005-09-06 13:16 Duran's technical life 閱讀(4205) | 評論 (2)編輯 收藏
     
    1  Open the Apache Tomcat configuration app in sys tray, and on the "Java" tab, bump up the initial memory pool size and the maximum memory pool size to 512 Initial and 768 Max, click Ok.
    2  In \Program Files\Apache software Foundation\Tomcat 5.0\bin\catalina.bat, in the last section immediately after "rem Execute Java with the applicable properties", insert this line, set CATALINA_OPTS=-mx1024m. Save the file.
    posted @ 2005-08-12 17:38 Duran's technical life 閱讀(1605) | 評論 (0)編輯 收藏
     

    在google里敲了“HelloWolrd”,再點“手氣不錯”,出來了這樣一個頁面:http://www2.latech.edu/~acm/HelloWorld.shtml

    Hello World!

    Welcome to the ACM "Hello World" project. Everyone has seen the Hello World program used as a first exposure to a new language or environment. We are attempting to collect examples for as many languages and related programming environments (shells etc.) as possible.


    Aproximate number of examples:204     <----wow~~~
    This page has been accessed 33274 times.
    Last updated: January 20, 2005   


    看看C的,經(jīng)典HelloWorld
    #include <stdio.h>
    main()
    {
      for(;;)
          {
              printf ("Hello World!\n");
          }
    }


    這也是HelloWolrd?!
    a 1986 entry from Bruce Holloway:

    #include "stdio.h"
    #define e 3
    #define g (e/e)
    #define h ((g+e)/2)
    #define f (e-g-h)
    #define j (e*e-g)
    #define k (j-h)
    #define l(x) tab2[x]/h
    #define m(n,a) ((n&(a))==(a))

    long tab1[]={ 989L,5L,26L,0L,88319L,123L,0L,9367L };
    int tab2[]={ 4,6,10,14,22,26,34,38,46,58,62,74,82,86 };

    main(m1,s) char *s; {
        int a,b,c,d,o[k],n=(int)s;
        if(m1==1){ char b[2*j+f-g]; main(l(h+e)+h+e,b); printf(b); }
        else switch(m1-=h){
            case f:
                a=(b=(c=(d=g)<<g)<'<g)<<g;
                return(m(n,a|c)|m(n,b)|m(n,a|d)|m(n,c|d));
            case h:
                for(a=f;a=e)for(b=g<<g;b<n;++b)o[b]=o[b-h]+o[b-g]+c;
                return(o[b-g]%n+k-h);
            default:
                if(m1-=e) main(m1-g+e+h,s+g); else *(s+g)=f;
                for(*s=a=f;a<e;) *s=(*s<<e)|main(h+a++,(char *)m1);
            }
    }

    曾經(jīng)最短的HelloWorld(Jari.Arkko@lmf.eua.ericsson.se
    jar.1.c
    char*_="Hello world.\n";

    ln -s /dev/tty jar.1.o
    cc -c jar.1.c



    現(xiàn)在最短的HelloWorld (Jyrki Holopainen)
    ";main(){puts("Hello World!");}char*C=".c  
    char*_=__FILE__;

    posted @ 2005-08-09 09:38 Duran's technical life 閱讀(633) | 評論 (0)編輯 收藏
     
    主站蜘蛛池模板: eeuss草民免费| 成人黄色免费网站| 亚洲制服中文字幕第一区| 日本片免费观看一区二区| 亚洲首页国产精品丝袜| 啊v在线免费观看| 久久这里只精品国产免费10| 亚洲一级黄色大片| 亚洲一区无码精品色| ww在线观视频免费观看| 免费看一级高潮毛片| 蜜芽亚洲av无码精品色午夜| 国产精品无码免费视频二三区| 日韩免费高清一级毛片在线| 曰批全过程免费视频免费看| 蜜芽亚洲av无码精品色午夜| 一区二区三区亚洲视频| 亚洲精品在线免费看| 一级毛片免费在线| 亚洲校园春色另类激情| 国产成人A人亚洲精品无码| 四虎成人免费网址在线| 久久99精品视免费看| 美女黄频a美女大全免费皮| 亚洲福利电影一区二区?| 精品亚洲成α人无码成α在线观看| 无遮挡免费一区二区三区| 91亚洲自偷手机在线观看| 亚洲国产成人久久综合野外| 国产1000部成人免费视频| 一级特黄色毛片免费看| 国产精品久久亚洲不卡动漫| 亚洲国产精品成人久久| 亚洲国产人成精品| 成人免费视频网址| 7m凹凸精品分类大全免费| 色www永久免费网站| 午夜不卡AV免费| 免费在线人人电影网| 亚洲色偷偷综合亚洲AV伊人蜜桃| 四虎影院永久免费观看|