select * from USER where name like '%hoge%';


S2Daoで表現するとき、よくこういう風に書いてしまいがち

select * from USER where name like '%/*name*/%'

でも、こうするとnameの後ろの%が消されてしまい、まともなSQLが生成されない

だからこんな感じにする

select * from USER where name like ('%' + /*name*/'hogehoge' +'%')

こうすれば、後ろのhogehogeはなくなってlike検索ができるようになるぜ

はまった。。。。

客先のtomcatがどうも遅いらしい。
色々調べた結果、tomcatインストール時のオプションで、
Windows Nativeなライブラリ(JNI)を使うと、遅くなったり不安定になることがあるらしい。
インストール時の資料として、オプションの設定を残すことと、マイナーバージョンまで抑えておくことが
大切だということを学ぶ。


それにしても、JNIの存在をようやく知った。
JavaからWindows APIなどのプラットフォーム依存のAPIを直接たたくためのラッパらしい。
ちょっと勉強してみようと思う。

よかったとおもう記事

組み込み開発フォーラム - MONOist(モノイスト)

テストをしてもらうにも、テスト仕様書がないとかひどいこともあったり。

コボコラを大量に集めてみた - phaの日記

シュールすぎて、面白かった。

[reading]戦うプログラマー

闘うプログラマー 上巻

闘うプログラマー 上巻

マイクロソフトでのNT開発の激闘の日々の小説。
ワーカホリックには到底なれないなと思った。
そこまで、仕事に打ち込める心境にはとても到達できないよ。

[api][perl]amazonのほしいものリストを取得した。

amazonのExampleを改造して作った。
apiを利用するプログラムを始めて書いたが、XPathの使いかたが分かったのは、よかったと思う。
また、いろいろなapiを使って遊んで見ようと思う。

概要

  • amazonapiを利用するには。Amazonへのアクセスキーが必要
  • ほしいものリスト(wishlist)を取得するには、wishlistを特定するListIdが必要
  • ほしいものリストを取得した時に、取得できるアイテム数は1度に10個までなので、すべてのアイテムを取得するために、ProductPageをループさせた。

ソース

#!/usr/bin/perl

use strict;
use warnings;
use LWP::UserAgent qw($ua get);
use MIME::Base64;
use XML::XPath;
use Date::Format;

# Define the parameters in the REST request.
# Customer cannot change the following values.
my $EndPoint = "http://ecs.amazonaws.jp/onca/xml";
my $service = "AWSECommerceService";
my $accesskey = "XXXXXXXXXX";
my $operation = "ListLookup";
my $listType = "WishList";
my $listId="AAAAAAAA";
my $responseGroup="ItemAttributes";
my $condition="All";
my $version = "2008-08-19";

for(my $productPage=1; $productPage<=999; $productPage++){
# Assemble the REST request URL.
    my $request =
        "$EndPoint?" .
        "Service=$service&" .
        "AWSAccessKeyId=$accesskey&" .
        "Operation=$operation&" .
        "ListType=$listType&" .
        "ListId=$listId&" .
        "ResponseGroup=$responseGroup&" .
        "Condition=$condition&" .
        "ProductPage=$productPage&" .
        "Version=$version";

# Send the request using HTTP GET.
    my $ua = new LWP::UserAgent;
    $ua->timeout(30);
    my $response = $ua->get($request);
    my $xml = $response->content;
    
    my $xp = XML::XPath->new(xml => $xml);
    
##XPathを使ってエラーがあれば、ブレイク
    if ( $xp->find("//Error") )
    {
#        print "There was an error processing your request:\n", 
#        "  Error code: ", $xp->findvalue("//Error/Code"), "\n",
#        "  ", $xp->findvalue("//Error/Message"), "\n\n";
        last;
    }
    
#Xpathをつかって、アイテム1つ1つに対して、処理を行う。
    {
        for (my $i=1; $i<=10; $i++){
            if (! $xp->find("/ListLookupResponse/Lists/List/ListItem[$i]")){
                last;
            }
#            print "ASIN  : ", $xp->findvalue("/ListLookupResponse/Lists/List/ListItem[$i]/Item/ASIN"),"\n";
#            print "detailPageUrl  : ", $xp->findvalue("/ListLookupResponse/Lists/List/ListItem[$i]/Item/DetailPageURL"),"\n";
#            print "Author: ", $xp->find("/ListLookupResponse/Lists/List/ListItem[$i]/Item/ItemAttributes/Author"), "\n";
#            print "ISBN: ", $xp->find("/ListLookupResponse/Lists/List/ListItem[$i]/Item/ItemAttributes/ISBN"), 
            print"TITLE:", $xp->find("/ListLookupResponse/Lists/List/ListItem[$i]/Item/ItemAttributes/Title"), "  ";
            print "Price: ", $xp->find("/ListLookupResponse/Lists/List/ListItem[$i]/Item/ItemAttributes/ListPrice/FormattedPrice"), "\n";
        }
    }    
}

参考にしたサイト