国产精品综合av一区二区国产馆,精品中文字幕一区二区三区,精品一区二区三区影院在线午夜http://www.aygfsteel.com/luyongfa/zh-cnThu, 03 Jul 2025 11:24:39 GMTThu, 03 Jul 2025 11:24:39 GMT60SQL優(yōu)化http://www.aygfsteel.com/luyongfa/articles/429429.htmlMr.luMr.luThu, 25 Feb 2016 06:24:00 GMThttp://www.aygfsteel.com/luyongfa/articles/429429.htmlhttp://www.aygfsteel.com/luyongfa/comments/429429.htmlhttp://www.aygfsteel.com/luyongfa/articles/429429.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/429429.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/429429.html1.對(duì)查詢進(jìn)行優(yōu)化,要盡量避免全表掃描,首先應(yīng)考慮在 where 及 order by 涉及的列上建立索引。

2.應(yīng)盡量避免在 where 子句中對(duì)字段進(jìn)行 null 值判斷,否則將導(dǎo)致引擎放棄使用索引而進(jìn)行全表掃描,如:

select id from t where num is null

最好不要給數(shù)據(jù)庫留NULL,盡可能的使用 NOT NULL填充數(shù)據(jù)庫.

備注、描述、評(píng)論之類的可以設(shè)置為 NULL,其他的,最好不要使用NULL。

不要以為 NULL 不需要空間,比如:char(100) 型,在字段建立時(shí),空間就固定了, 不管是否插入值(NULL也包含在內(nèi)),都是占用 100個(gè)字符的空間的,如果是varchar這樣的變長字段, null 不占用空間。

可以在num上設(shè)置默認(rèn)值0,確保表中num列沒有null值,然后這樣查詢:

select id from t where num = 0

3.應(yīng)盡量避免在 where 子句中使用 != 或 <> 操作符,否則將引擎放棄使用索引而進(jìn)行全表掃描。

4.應(yīng)盡量避免在 where 子句中使用 or 來連接條件,如果一個(gè)字段有索引,一個(gè)字段沒有索引,將導(dǎo)致引擎放棄使用索引而進(jìn)行全表掃描,如:

select id from t where num=10 or Name = 'admin'

可以這樣查詢:

select id from t where num = 10 union all select id from t where Name = 'admin'

5.in 和 not in 也要慎用,否則會(huì)導(dǎo)致全表掃描,如:

select id from t where num in(1,2,3)

對(duì)于連續(xù)的數(shù)值,能用 between 就不要用 in 了

select id from t where num between 1 and 3

很多時(shí)候用 exists 代替 in 是一個(gè)好的選擇:

select num from a where num in(select num from b)

用下面的語句替換:

select num from a where exists(select 1 from b where num=a.num)

6.下面的查詢也將導(dǎo)致全表掃描:

select id from t where name like%abc%

若要提高效率,可以考慮全文檢索。

7.如果在 where 子句中使用參數(shù),也會(huì)導(dǎo)致全表掃描。因?yàn)镾QL只有在運(yùn)行時(shí)才會(huì)解析局部變量,但優(yōu)化程序不能將訪問計(jì)劃的選擇推遲到運(yùn)行時(shí);它必須在編譯時(shí)進(jìn)行選擇。然 而,如果在編譯時(shí)建立訪問計(jì)劃,變量的值還是未知的,因而無法作為索引選擇的輸入項(xiàng)。如下面語句將進(jìn)行全表掃描:

select id from t where num = @num

可以改為強(qiáng)制查詢使用索引:

select id from t with(index(索引名)) where num = @num

應(yīng)盡量避免在 where 子句中對(duì)字段進(jìn)行表達(dá)式操作,這將導(dǎo)致引擎放棄使用索引而進(jìn)行全表掃描。如:

select id from t where num/2 = 100

應(yīng)改為:

select id from t where num = 100*2

9.應(yīng)盡量避免在where子句中對(duì)字段進(jìn)行函數(shù)操作,這將導(dǎo)致引擎放棄使用索引而進(jìn)行全表掃描。如:

select id from t where substring(name,1,3) = ’abc’       -–name以abc開頭的id select id from t where datediff(day,createdate,’2005-11-30′) = 0    -–‘2005-11-30’    --生成的id

應(yīng)改為:

select id from t where name like 'abc%' select id from t where createdate >= '2005-11-30' and createdate < '2005-12-1'

10.不要在 where 子句中的“=”左邊進(jìn)行函數(shù)、算術(shù)運(yùn)算或其他表達(dá)式運(yùn)算,否則系統(tǒng)將可能無法正確使用索引。

11.在使用索引字段作為條件時(shí),如果該索引是復(fù)合索引,那么必須使用到該索引中的第一個(gè)字段作為條件時(shí)才能保證系統(tǒng)使用該索引,否則該索引將不會(huì)被使用,并且應(yīng)盡可能的讓字段順序與索引順序相一致。

12.不要寫一些沒有意義的查詢,如需要生成一個(gè)空表結(jié)構(gòu):

select col1,col2 into #t from t where 1=0

這類代碼不會(huì)返回任何結(jié)果集,但是會(huì)消耗系統(tǒng)資源的,應(yīng)改成這樣:

create table #t(…)

13.Update 語句,如果只更改1、2個(gè)字段,不要Update全部字段,否則頻繁調(diào)用會(huì)引起明顯的性能消耗,同時(shí)帶來大量日志。

14.對(duì)于多張大數(shù)據(jù)量(這里幾百條就算大了)的表JOIN,要先分頁再JOIN,否則邏輯讀會(huì)很高,性能很差。

15.select count(*) from table;這樣不帶任何條件的count會(huì)引起全表掃描,并且沒有任何業(yè)務(wù)意義,是一定要杜絕的。

16.索引并不是越多越好,索引固然可以提高相應(yīng)的 select 的效率,但同時(shí)也降低了 insert 及 update 的效率,因?yàn)?insert 或 update 時(shí)有可能會(huì)重建索引,所以怎樣建索引需要慎重考慮,視具體情況而定。一個(gè)表的索引數(shù)最好不要超過6個(gè),若太多則應(yīng)考慮一些不常使用到的列上建的索引是否有 必要。

17.應(yīng)盡可能的避免更新 clustered 索引數(shù)據(jù)列,因?yàn)?clustered 索引數(shù)據(jù)列的順序就是表記錄的物理存儲(chǔ)順序,一旦該列值改變將導(dǎo)致整個(gè)表記錄的順序的調(diào)整,會(huì)耗費(fèi)相當(dāng)大的資源。若應(yīng)用系統(tǒng)需要頻繁更新 clustered 索引數(shù)據(jù)列,那么需要考慮是否應(yīng)將該索引建為 clustered 索引。

18.盡量使用數(shù)字型字段,若只含數(shù)值信息的字段盡量不要設(shè)計(jì)為字符型,這會(huì)降低查詢和連接的性能,并會(huì)增加存儲(chǔ)開銷。這是因?yàn)橐嬖谔幚聿樵兒瓦B 接時(shí)會(huì)逐個(gè)比較字符串中每一個(gè)字符,而對(duì)于數(shù)字型而言只需要比較一次就夠了。

19.盡可能的使用 varchar/nvarchar 代替 char/nchar ,因?yàn)槭紫茸冮L字段存儲(chǔ)空間小,可以節(jié)省存儲(chǔ)空間,其次對(duì)于查詢來說,在一個(gè)相對(duì)較小的字段內(nèi)搜索效率顯然要高些。

20.任何地方都不要使用 select * from t ,用具體的字段列表代替“*”,不要返回用不到的任何字段

21.盡量使用表變量來代替臨時(shí)表。如果表變量包含大量數(shù)據(jù),請(qǐng)注意索引非常有限(只有主鍵索引)。

22. 避免頻繁創(chuàng)建和刪除臨時(shí)表,以減少系統(tǒng)表資源的消耗。臨時(shí)表并不是不可使用,適當(dāng)?shù)厥褂盟鼈兛梢允鼓承├谈行В纾?dāng)需要重復(fù)引用大型表或常用表中的某個(gè)數(shù)據(jù)集時(shí)。但是,對(duì)于一次性事件, 最好使用導(dǎo)出表。

23.在新建臨時(shí)表時(shí),如果一次性插入數(shù)據(jù)量很大,那么可以使用 select into 代替 create table,避免造成大量 log ,以提高速度;如果數(shù)據(jù)量不大,為了緩和系統(tǒng)表的資源,應(yīng)先create table,然后insert。

24.如果使用到了臨時(shí)表,在存儲(chǔ)過程的最后務(wù)必將所有的臨時(shí)表顯式刪除,先 truncate table ,然后 drop table ,這樣可以避免系統(tǒng)表的較長時(shí)間鎖定。

25.盡量避免使用游標(biāo),因?yàn)橛螛?biāo)的效率較差,如果游標(biāo)操作的數(shù)據(jù)超過1萬行,那么就應(yīng)該考慮改寫。

26.使用基于游標(biāo)的方法或臨時(shí)表方法之前,應(yīng)先尋找基于集的解決方案來解決問題,基于集的方法通常更有效。

27.與臨時(shí)表一樣,游標(biāo)并不是不可使用。對(duì)小型數(shù)據(jù)集使用 FAST_FORWARD 游標(biāo)通常要優(yōu)于其他逐行處理方法,尤其是在必須引用幾個(gè)表才能獲得所需的數(shù)據(jù)時(shí)。在結(jié)果集中包括“合計(jì)”的例程通常要比使用游標(biāo)執(zhí)行的速度快。如果開發(fā)時(shí) 間允許,基于游標(biāo)的方法和基于集的方法都可以嘗試一下,看哪一種方法的效果更好。

28.在所有的存儲(chǔ)過程和觸發(fā)器的開始處設(shè)置 SET NOCOUNT ON ,在結(jié)束時(shí)設(shè)置 SET NOCOUNT OFF 。無需在執(zhí)行存儲(chǔ)過程和觸發(fā)器的每個(gè)語句后向客戶端發(fā)送 DONE_IN_PROC 消息。

29.盡量避免大事務(wù)操作,提高系統(tǒng)并發(fā)能力。

30.盡量避免向客戶端返回大數(shù)據(jù)量,若數(shù)據(jù)量過大,應(yīng)該考慮相應(yīng)需求是否合理。

實(shí)際案例分析:拆分大的 DELETE 或INSERT 語句,批量提交SQL語句

如果你需要在一個(gè)在線的網(wǎng)站上去執(zhí)行一個(gè)大的 DELETE 或 INSERT 查詢,你需要非常小心,要避免你的操作讓你的整個(gè)網(wǎng)站停止相應(yīng)。因?yàn)檫@兩個(gè)操作是會(huì)鎖表的,表一鎖住了,別的操作都進(jìn)不來了。

Apache 會(huì)有很多的子進(jìn)程或線程。所以,其工作起來相當(dāng)有效率,而我們的服務(wù)器也不希望有太多的子進(jìn)程,線程和數(shù)據(jù)庫鏈接,這是極大的占服務(wù)器資源的事情,尤其是內(nèi)存。

如果你把你的表鎖上一段時(shí)間,比如30秒鐘,那么對(duì)于一個(gè)有很高訪問量的站點(diǎn)來說,這30秒所積累的訪問進(jìn)程/線程,數(shù)據(jù)庫鏈接,打開的文件數(shù),可能不僅僅會(huì)讓你的WEB服務(wù)崩潰,還可能會(huì)讓你的整臺(tái)服務(wù)器馬上掛了。

所以,如果你有一個(gè)大的處理,你一定把其拆分,使用 LIMIT oracle(rownum),sqlserver(top)條件是一個(gè)好的方法。下面是一個(gè)mysql示例:

 

 
while(1){   //每次只做1000條   mysql_query(“delete from logs where log_date <= ’2012-11-01’ limit 1000”);   if(mysql_affected_rows() == 0){
//刪除完成,退出! break; } //每次暫停一段時(shí)間,釋放表讓其他進(jìn)程/線程訪問。 usleep(50000) }


]]>
獲取八位UUID標(biāo)識(shí)碼http://www.aygfsteel.com/luyongfa/archive/2016/01/19/429112.htmlMr.luMr.luTue, 19 Jan 2016 07:17:00 GMThttp://www.aygfsteel.com/luyongfa/archive/2016/01/19/429112.htmlhttp://www.aygfsteel.com/luyongfa/comments/429112.htmlhttp://www.aygfsteel.com/luyongfa/archive/2016/01/19/429112.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/429112.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/429112.html public static String[] chars = new String[]
      {
          "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
          "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
          "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
      };

  public static String getShortUuid() {
    StringBuffer stringBuffer = new StringBuffer();
    String uuid = UUID.randomUUID().toString().replace("-", "");
    for (int i = 0; i < 8; i++) {
      String str = uuid.substring(i * 4, i * 4 + 4);
      int strInteger = Integer.parseInt(str, 16);
      stringBuffer.append(chars[strInteger % 0x3E]);
    }

    return stringBuffer.toString();
  }

]]>
Java開發(fā)必會(huì)的Linux命令http://www.aygfsteel.com/luyongfa/archive/2015/12/25/428823.htmlMr.luMr.luFri, 25 Dec 2015 02:13:00 GMThttp://www.aygfsteel.com/luyongfa/archive/2015/12/25/428823.htmlhttp://www.aygfsteel.com/luyongfa/comments/428823.htmlhttp://www.aygfsteel.com/luyongfa/archive/2015/12/25/428823.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/428823.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/428823.html本文并不會(huì)對(duì)所有命令進(jìn)行詳細(xì)講解,只給出常見用法和解釋。具體用法可以使用--help查看幫助或者直接通過google搜索學(xué)習(xí)。

1.查找文件

find / -name filename.txt 根據(jù)名稱查找/目錄下的filename.txt文件。

find . -name "*.xml" 遞歸查找所有的xml文件

find . -name "*.xml" |xargs grep "hello world" 遞歸查找所有文件內(nèi)容中包含hello world的xml文件

grep -H 'spring' *.xml 查找所以有的包含spring的xml文件

find ./ -size 0 | xargs rm -f & 刪除文件大小為零的文件

ls -l | grep '.jar' 查找當(dāng)前目錄中的所有jar文件

grep 'test' d* 顯示所有以d開頭的文件中包含test的行。

grep 'test' aa bb cc 顯示在aa,bb,cc文件中匹配test的行。

grep '[a-z]\{5\}' aa 顯示所有包含每個(gè)字符串至少有5個(gè)連續(xù)小寫字符的字符串的行。

2.查看一個(gè)程序是否運(yùn)行

ps –ef|grep tomcat 查看所有有關(guān)tomcat的進(jìn)程

3.終止線程

kill -9 19979 終止線程號(hào)位19979的進(jìn)程

4.查看文件,包含隱藏文件

ls -al

5.當(dāng)前工作目錄

pwd

6.復(fù)制文件

cp source dest 復(fù)制文件

cp -r sourceFolder targetFolder 遞歸復(fù)制整個(gè)文件夾

scp sourecFile romoteUserName@remoteIp:remoteAddr 遠(yuǎn)程拷貝

7.創(chuàng)建目錄

mkdir newfolder

8.刪除目錄

rmdir deleteEmptyFolder 刪除空目錄 rm -rf deleteFile 遞歸刪除目錄中所有內(nèi)容

9.移動(dòng)文件

mv /temp/movefile /targetFolder

10.重命令

mv oldNameFile newNameFile

11.切換用戶

su -username

12.修改文件權(quán)限

chmod 777 file.java //file.java的權(quán)限-rwxrwxrwx,r表示讀、w表示寫、x表示可執(zhí)行

13.壓縮文件

tar -czf test.tar.gz /test1 /test2

14.列出壓縮文件列表

tar -tzf test.tar.gz

15.解壓文件

tar -xvzf test.tar.gz

16.查看文件頭10行

head -n 10 example.txt

17.查看文件尾10行

tail -n 10 example.txt

18.查看日志類型文件

tail -f exmaple.log //這個(gè)命令會(huì)自動(dòng)顯示新增內(nèi)容,屏幕只顯示10行內(nèi)容的(可設(shè)置)。

19.使用超級(jí)管理員身份執(zhí)行命令

sudo rm a.txt 使用管理員身份刪除文件

20.查看端口占用情況

netstat -tln | grep 8080 查看端口8080的使用情況

21.查看端口屬于哪個(gè)程序

lsof -i :8080

22.查看進(jìn)程

ps aux|grep java 查看java進(jìn)程

ps aux 查看所有進(jìn)程

23.以樹狀圖列出目錄的內(nèi)容

tree a

ps:Mac下使用tree命令

24. 文件下載

wget http://file.tgz mac下安裝wget命令

curl http://file.tgz

25. 網(wǎng)絡(luò)檢測

ping www.just-ping.com

26.遠(yuǎn)程登錄

ssh userName@ip

27.打印信息

echo $JAVA_HOME 打印java home環(huán)境變量的值

28.java 常用命令

java javac jps ,jstat ,jmapjstack

29.其他命令

svn git maven

28.linux命令學(xué)習(xí)網(wǎng)站:

http://explainshell.com/



]]>
常用 Git 命令清單http://www.aygfsteel.com/luyongfa/archive/2015/12/21/428759.htmlMr.luMr.luMon, 21 Dec 2015 05:37:00 GMThttp://www.aygfsteel.com/luyongfa/archive/2015/12/21/428759.htmlhttp://www.aygfsteel.com/luyongfa/comments/428759.htmlhttp://www.aygfsteel.com/luyongfa/archive/2015/12/21/428759.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/428759.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/428759.html閱讀全文

]]>
Redis的Java客戶端Jedis的八種調(diào)用方式(事務(wù)、管道、分布式)介紹http://www.aygfsteel.com/luyongfa/archive/2015/04/03/424099.htmlMr.luMr.luFri, 03 Apr 2015 05:28:00 GMThttp://www.aygfsteel.com/luyongfa/archive/2015/04/03/424099.htmlhttp://www.aygfsteel.com/luyongfa/comments/424099.htmlhttp://www.aygfsteel.com/luyongfa/archive/2015/04/03/424099.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/424099.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/424099.html閱讀全文

]]>
bitbucket入門手冊,手把手操作指南http://www.aygfsteel.com/luyongfa/archive/2015/03/11/423365.htmlMr.luMr.luWed, 11 Mar 2015 02:40:00 GMThttp://www.aygfsteel.com/luyongfa/archive/2015/03/11/423365.htmlhttp://www.aygfsteel.com/luyongfa/comments/423365.htmlhttp://www.aygfsteel.com/luyongfa/archive/2015/03/11/423365.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/423365.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/423365.htmlBitbucket使用說明:


使用者請(qǐng)直接看第一步,第二步和egit使用說明,


需要自己創(chuàng)建倉庫的可以看三四步


第一步:新用戶注冊www.bitbucket.org


 


然后按步驟創(chuàng)建一個(gè)教程代碼庫

 


可以選擇下載SourceTree git   SourceTree是一個(gè)客戶端,圖形界面,挺方便的

 

 

主界面有個(gè)教程,挺詳細(xì)的,可以看看

 

 


第二步:設(shè)置中文


點(diǎn)右上角的小人圖標(biāo),然后點(diǎn)擊“Manage account”

 

Account settings 里最下面有個(gè)選項(xiàng),Language,改成Chinese


 


第三步:創(chuàng)建倉庫


  

  

 

 

創(chuàng)建完可以用SourceTree復(fù)制代碼進(jìn)去,點(diǎn)擊用SourceTree克隆

  


會(huì)彈出這個(gè)窗口,可以更改目標(biāo)路徑(必須是空文件夾,不存在的最好)

 

 

里面現(xiàn)在是空的,點(diǎn)擊在文件管理器中打開

 

 

把代碼復(fù)制到這個(gè)文件夾

 

然后查看SourceTree,里面就有未保存的文件(如果沒有,點(diǎn)擊下日志/歷史)點(diǎn)擊“未暫存的文件” 



就會(huì)變成“已暫存的文件” 

 


然后點(diǎn)擊工具欄的”提交”

 

 

輸入需要說明的文字,點(diǎn)擊提交

 

 

 

 

這時(shí)候你可以看到分支那里有了東西,不過這個(gè)時(shí)候還只是在你的本地

 

 

點(diǎn)擊推送,就會(huì)放到服務(wù)器上

 

 


 

點(diǎn)擊顯示完整輸出,可以看進(jìn)度,如果變綠,出現(xiàn)執(zhí)行成功,就行了,文件多會(huì)稍微慢點(diǎn)

 

 

 

 

然后去網(wǎng)站,刷新一下頁面,就會(huì)出來信息

 

 

 

 

 


第四步:管理倉庫


源碼部分可以下載和查看源碼

 


 

提交部分可以查看提交記錄

 



 

點(diǎn)擊提交下面的藍(lán)字,可以查看這個(gè)版本修部分,每個(gè)變化文件都會(huì)顯示出來,紅色表示刪除代碼,綠表示添加代碼,十分方便查看這個(gè)版本更新了什么,

 

 

 

旁邊的通知圖標(biāo)可以留言評(píng)論

 

 

 


第五步:代碼更新


代碼更新的一般步驟:克隆代碼——修改——提交——推送

Eclipse可以用egit方便完成,Qtgit工具,Vsgit插件,其他情況可以用sourceTree完成

具體的,可以查詢其他資料,因?yàn)槲夷壳笆怯胘ava,我會(huì)再寫一個(gè)egit的使用方法



]]>
SQL關(guān)于分組合并字段解決方案http://www.aygfsteel.com/luyongfa/articles/421990.htmlMr.luMr.luWed, 31 Dec 2014 07:49:00 GMThttp://www.aygfsteel.com/luyongfa/articles/421990.htmlhttp://www.aygfsteel.com/luyongfa/comments/421990.htmlhttp://www.aygfsteel.com/luyongfa/articles/421990.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/421990.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/421990.html之前遇到分組后合并某字段得問題,我都會(huì)自己去寫個(gè)函數(shù)去實(shí)現(xiàn)。直至今天我才知道,原來各個(gè)數(shù)據(jù)庫都提供了相關(guān)的函數(shù),只是我不知道罷了。
mysql提供的函數(shù)功能最為強(qiáng)大,oracle和postgresql提供的函數(shù)只能實(shí)現(xiàn)單個(gè)字段合并

1.mysql:group_concat函數(shù),demo如下:
表數(shù)據(jù):

SQL:SELECT group_concat(name,',',remark order by id desc separator ';'FROM test group by age;
運(yùn)行結(jié)果:


2.oracle:wmsys.wm_concat函數(shù),功能比較簡單,只能實(shí)現(xiàn)單字段間的合并,demo如下:
表數(shù)據(jù):


SQL:
SELECT DISTINCT
    wmsys.wm_concat (NAME) OVER (
        PARTITION BY AGE
        ORDER BY
            (SELECT 1 FROM dual)
    )
FROM
    (
        SELECT
            *
        FROM
            T_TEST
        ORDER BY
            ID DESC
    ) T
結(jié)果:


3.Postgresql:array_to_string以及string_agg兩個(gè)函數(shù)都能實(shí)現(xiàn),推薦string_agg,demo如下:
表數(shù)據(jù):

SQL:
     SELECT id,array_to_string(ARRAY(SELECT unnest(array_agg(name)) order by 1),';'FROM t_kenyon GROUP BY id ORDER BY id;

     SELECT id,string_agg(name,';'FROM t_kenyon GROUP BY id ORDER BY id;
結(jié)果:



]]>
獲取ApplicationContexthttp://www.aygfsteel.com/luyongfa/archive/2014/12/26/421863.htmlMr.luMr.luFri, 26 Dec 2014 09:06:00 GMThttp://www.aygfsteel.com/luyongfa/archive/2014/12/26/421863.htmlhttp://www.aygfsteel.com/luyongfa/comments/421863.htmlhttp://www.aygfsteel.com/luyongfa/archive/2014/12/26/421863.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/421863.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/421863.html一、簡單的用ApplicationContext做測試的話,獲得Spring中定義的Bean實(shí)例(對(duì)象).可以用:

ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
RegisterDAO registerDAO = (RegisterDAO)ac.getBean("RegisterDAO");

如果是兩個(gè)以上:
ApplicationContext ac = new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml","dao.xml"});

或者用通配符:
ApplicationContext ac = new ClassPathXmlApplicationContext("classpath:/*.xml");


二、ClassPathXmlApplicationContext[只能讀放在web-info/classes目錄下的配置文件]和FileSystemXmlApplicationContext的區(qū)別

classpath:前綴是不需要的,默認(rèn)就是指項(xiàng)目的classpath路徑下面;
如果要使用絕對(duì)路徑,需要加上file:前綴表示這是絕對(duì)路徑;

對(duì)于FileSystemXmlApplicationContext:
默認(rèn)表示的是兩種:

1.沒有盤符的是項(xiàng)目工作路徑,即項(xiàng)目的根目錄;
2.有盤符表示的是文件絕對(duì)路徑.

如果要使用classpath路徑,需要前綴classpath:

public class HelloClient {

  protected static final Log log = LogFactory.getLog(HelloClient.class);

  public static void main(String[] args) {
    // Resource resource = new ClassPathResource("appcontext.xml");
    // BeanFactory factory = new XmlBeanFactory(resource);

    // 用classpath路徑
    // ApplicationContext factory = new ClassPathXmlApplicationContext("classpath:appcontext.xml");
    // ApplicationContext factory = new ClassPathXmlApplicationContext("appcontext.xml");

    // ClassPathXmlApplicationContext使用了file前綴是可以使用絕對(duì)路徑的
    // ApplicationContext factory = new ClassPathXmlApplicationContext("file:F:/workspace/example/src/appcontext.xml");

    // 用文件系統(tǒng)的路徑,默認(rèn)指項(xiàng)目的根路徑
    // ApplicationContext factory = new FileSystemXmlApplicationContext("src/appcontext.xml");
    // ApplicationContext factory = new FileSystemXmlApplicationContext("webRoot/WEB-INF/appcontext.xml");

    // 使用了classpath:前綴,這樣,FileSystemXmlApplicationContext也能夠讀取classpath下的相對(duì)路徑
    // ApplicationContext factory = new FileSystemXmlApplicationContext("classpath:appcontext.xml");
    // ApplicationContext factory = new FileSystemXmlApplicationContext("file:F:/workspace/example/src/appcontext.xml");

    // 不加file前綴
    ApplicationContext factory = new FileSystemXmlApplicationContext("F:/workspace/example/src/appcontext.xml");
    IHelloWorld hw = (IHelloWorld)factory.getBean("helloworldbean");
    log.info(hw.getContent("luoshifei"));
  }
}



]]>
solr4刪除索引 http://www.aygfsteel.com/luyongfa/articles/413630.htmlMr.luMr.luTue, 13 May 2014 14:11:00 GMThttp://www.aygfsteel.com/luyongfa/articles/413630.htmlhttp://www.aygfsteel.com/luyongfa/comments/413630.htmlhttp://www.aygfsteel.com/luyongfa/articles/413630.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/413630.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/413630.html

通過web方式提交索引和刪除索引


Solr 刪除指定索引:
http://localhost:8081/solr/solrtest/update/?stream.body=solr123456&stream.contentType=text/xml;charset=utf-8&commit=true

 

Solr 刪除全部索引:http://localhost:8080/solr/update/?stream.body=*:*&stream.contentType=text/xml;charset=utf-8&commit=true

 



]]>
SolrJ開發(fā)文檔 http://www.aygfsteel.com/luyongfa/articles/412776.htmlMr.luMr.luTue, 22 Apr 2014 02:40:00 GMThttp://www.aygfsteel.com/luyongfa/articles/412776.htmlhttp://www.aygfsteel.com/luyongfa/comments/412776.htmlhttp://www.aygfsteel.com/luyongfa/articles/412776.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/412776.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/412776.html閱讀全文

]]>
ajax跨域請(qǐng)求http://www.aygfsteel.com/luyongfa/archive/2013/12/26/408047.htmlMr.luMr.luThu, 26 Dec 2013 01:24:00 GMThttp://www.aygfsteel.com/luyongfa/archive/2013/12/26/408047.htmlhttp://www.aygfsteel.com/luyongfa/comments/408047.htmlhttp://www.aygfsteel.com/luyongfa/archive/2013/12/26/408047.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/408047.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/408047.html            type : "get",
            async:false,
            url : url,
            dataType : "jsonp",
            success : function(data){
                var param = data.status;
                if ("1" == param) {
                    window.location.reload();
                }
                alert(data.message);
            },
            error:function(){
                alert('操作失敗');
            }
        });


服務(wù)端:
      String cb = request.getParameter("callback");
            if (cb != null) {//如果是跨域
                StringBuffer sb = new StringBuffer(cb);
                sb.append("(");
                sb.append(result);
                sb.append(")");
            }

]]>
Linux下Tomcat的啟動(dòng)、關(guān)閉、殺死進(jìn)程 http://www.aygfsteel.com/luyongfa/archive/2013/08/28/403399.htmlMr.luMr.luWed, 28 Aug 2013 05:14:00 GMThttp://www.aygfsteel.com/luyongfa/archive/2013/08/28/403399.htmlhttp://www.aygfsteel.com/luyongfa/comments/403399.htmlhttp://www.aygfsteel.com/luyongfa/archive/2013/08/28/403399.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/403399.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/403399.html打開終端
cd /java/tomcat
#執(zhí)行
bin/startup.sh #啟動(dòng)tomcat
bin/shutdown.sh #停止tomcat
tail -f logs/catalina.out #看tomcat的控制臺(tái)輸出;
 
#看是否已經(jīng)有tomcat在運(yùn)行了
ps -ef |grep tomcat
#如果有,用kill;
kill -9 pid #pid 為相應(yīng)的進(jìn)程號(hào)
 
例如 ps -ef |grep tomcat 輸出如下
sun 5144 1 0 10:21 pts/1 00:00:06 /java/jdk/bin/java -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/java/tomcat/common/endorsed -classpath :/java/tomcat/bin/bootstrap.jar:/java/tomcat/bin/commons-logging-api.jar -Dcatalina.base=/java/tomcat -Dcatalina.home=/java/tomcat -Djava.io.tmpdir=/java/tomcat/temp org.apache.catalina.startup.Bootstrap start
 
則 5144 就為進(jìn)程號(hào) pid = 5144
kill -9 5144 就可以徹底殺死tomcat
 
#直接查看指定端口的進(jìn)程pid
netstat -anp|grep 9217
#結(jié)果為 tcp        0      0 :::9217                     :::*                        LISTEN      26127/java
#則26127為9217這個(gè)端口的tomcat進(jìn)程的pid,然后就可以kill這個(gè)進(jìn)程
kill -9 26127
#然后再啟動(dòng)tomcat即可


]]>
在CentOS6.3上如何用yum安裝nginxhttp://www.aygfsteel.com/luyongfa/archive/2013/08/28/403393.htmlMr.luMr.luWed, 28 Aug 2013 02:25:00 GMThttp://www.aygfsteel.com/luyongfa/archive/2013/08/28/403393.htmlhttp://www.aygfsteel.com/luyongfa/comments/403393.htmlhttp://www.aygfsteel.com/luyongfa/archive/2013/08/28/403393.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/403393.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/403393.html默認(rèn)的yum源比較老也不全,在update這的那的之后,還是沒有nginx的身影, 別折騰了, 標(biāo)準(zhǔn)包是沒有這玩意兒的。


    wget http://www.atomicorp.com/installers/atomic  #下載atomic yum源

    sh ./atomic   #安裝

    yum check-update  #更新yum軟件包

2、安裝nginx:


    yum install nginx      #安裝nginx,根據(jù)提示,輸入Y安裝即可成功安裝

    #修改配置文件,這里省略,主要是將目錄指定到 /home/ngmsw-files

    service nginx start    #啟動(dòng)

    chkconfig  nginx on    #設(shè)為開機(jī)啟動(dòng)


]]>
在Centos下啟用mysql的遠(yuǎn)程訪問賬號(hào) http://www.aygfsteel.com/luyongfa/archive/2013/08/28/403389.htmlMr.luMr.luWed, 28 Aug 2013 02:10:00 GMThttp://www.aygfsteel.com/luyongfa/archive/2013/08/28/403389.htmlhttp://www.aygfsteel.com/luyongfa/comments/403389.htmlhttp://www.aygfsteel.com/luyongfa/archive/2013/08/28/403389.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/403389.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/403389.html在默認(rèn)情況下mysql是不允許遠(yuǎn)程訪問的.

現(xiàn)在需要添加一個(gè)可以具有原創(chuàng)訪問的mysql賬號(hào)(需要進(jìn)入mysql命令行下):

GRANT ALL PRIVILEGES ON *.* TO remote@"%" IDENTIFIED BY '遠(yuǎn)程登錄的明文密碼' WITH GRANT OPTION;

執(zhí)行如下語句生效:

flush privileges;



]]>
Linux下安裝jdk1.6 http://www.aygfsteel.com/luyongfa/archive/2013/08/27/403377.htmlMr.luMr.luTue, 27 Aug 2013 09:34:00 GMThttp://www.aygfsteel.com/luyongfa/archive/2013/08/27/403377.htmlhttp://www.aygfsteel.com/luyongfa/comments/403377.htmlhttp://www.aygfsteel.com/luyongfa/archive/2013/08/27/403377.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/403377.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/403377.html一、安裝

創(chuàng)建安裝目錄,在/usr/java下建立安裝路徑,并將文件考到該路徑下: 

# mkdir /usr/java

 

1、jdk-6u11-linux-i586.bin 這個(gè)是自解壓的文件,在linux上安裝如下: 

# chmod 755 jdk-6u11-linux-i586.bin 

# ./jdk-6u11-linux-i586.bin (注意,這個(gè)步驟一定要在jdk-6u11-linux-i586.bin所在目錄下)

在按提示輸入yes后,jdk被解壓。

 出現(xiàn)一行字:Do you aggree to the above license terms? [yes or no]

  安裝程序在問您是否愿意遵守剛才看過的許可協(xié)議。當(dāng)然要同意了,輸入"y" 或 "yes" 回車。

2、若是用jdk-6u11-linux-i586-rpm.bin 這個(gè)也是一個(gè)自解壓文件,不過解壓后的文件是jdk-6u11-linux-i586-rpm 包,執(zhí)行rpm命令裝到linux上就可以了。安裝如下: 

#chmod 755 ./jdk-6u11-linux-i586-rpm  

# ./jdk-6u11-linux-i586-rpm .bin 

# rpm -ivh jdk-6u11-linux-i586-rpm

 

出現(xiàn)一行字:Do you aggree to the above license terms? [yes or no]

  安裝程序在問您是否愿意遵守剛才看過的許可協(xié)議。當(dāng)然要同意了,輸入"y" 或 "yes" 回車。

安裝軟件會(huì)將JDK自動(dòng)安裝到 /usr/java/目錄下。 

二、配置
 #vi /etc/profile

  在里面添加如下內(nèi)容

export JAVA_HOME=/usr/java/jdk1.6.0_27

export JAVA_BIN=/usr/java/jdk1.6.0_27/bin

export PATH=$PATH:$JAVA_HOME/bin

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export JAVA_HOME JAVA_BIN PATH CLASSPATH

讓/etc/profile文件修改后立即生效 ,可以使用如下命令:

 # .  /etc/profile

注意: . 和 /etc/profile 有空格.


 
重啟測試

  java -version

  屏幕輸出:

  java version "jdk1.6.0_02"
  Java(TM) 2 Runtime Environment, Standard Edition (build jdk1.6.0_02)
  Java HotSpot(TM) Client VM (build jdk1.6.0_02, mixed mode)



]]>
Linux Tomcat安裝 http://www.aygfsteel.com/luyongfa/archive/2013/08/27/403376.htmlMr.luMr.luTue, 27 Aug 2013 09:33:00 GMThttp://www.aygfsteel.com/luyongfa/archive/2013/08/27/403376.htmlhttp://www.aygfsteel.com/luyongfa/comments/403376.htmlhttp://www.aygfsteel.com/luyongfa/archive/2013/08/27/403376.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/403376.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/403376.html 

  為了學(xué)習(xí)java,需要一個(gè)服務(wù)器,因此決定用比較流行的tomcat。根據(jù)網(wǎng)上對(duì)安裝tomcat的介紹,自己進(jìn)行了安裝,現(xiàn)在已經(jīng)成功了,現(xiàn)在把安裝的過程進(jìn)行記錄,也供大家學(xué)習(xí)參考。
   一、從官方網(wǎng)站上下載tomcat軟件包。
    http:
//tomcat.apache.org/
   點(diǎn)擊左側(cè)的 download的一個(gè)版本,我選擇的是 tomcat6.x,你可以根據(jù)自己的實(shí)際情況進(jìn)行選擇安裝,點(diǎn)擊超連接,選擇 Binary Distributions 下的tar.gz (pgp, md5) 壓縮包,進(jìn)行下載
   二、下載到本地后,進(jìn)行解壓

    #tar zxvf apach
-tomcat-6.0.16.tar.gz
    #mv apach
-tomcat-6.0.16 /usr/local

   三、進(jìn)行tomcat環(huán)境的配置(前提需要安裝jdk)
    #vi 
/etc/profile 

    export JAVA_HOME
=/usr/local/jdk1.6.0_04
     export TOMCAT_HOME
=/usr/local/apach-tomcat-6.0.16
    
    保存退出 
       
    # source 
/etc/profile  //讓當(dāng)前配置立即生效
    
    四、啟動(dòng)tomcat服務(wù)器 
    $ 
/usr/local/apach-tomcat-6.0.16/bin/startup.sh 
    我的電腦上會(huì)出現(xiàn)如下內(nèi)容: 
    Using CATALINA_BASE:   
/usr/local/apache-tomcat-6.0.16
    Using CATALINA_HOME:   
/usr/local/apache-tomcat-6.0.16
    Using CATALINA_TMPDIR: 
/usr/local/apache-tomcat-6.0.16/temp
    Using JRE_HOME:       
/usr/local/jdk1.6.0_04
    五、在瀏覽器中輸入http:
//localhost:8080/就可以看到tomcat的log了
    tomcat的安裝到此結(jié)束。

 



]]>
sql去重http://www.aygfsteel.com/luyongfa/archive/2013/08/27/403369.htmlMr.luMr.luTue, 27 Aug 2013 07:39:00 GMThttp://www.aygfsteel.com/luyongfa/archive/2013/08/27/403369.htmlhttp://www.aygfsteel.com/luyongfa/comments/403369.htmlhttp://www.aygfsteel.com/luyongfa/archive/2013/08/27/403369.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/403369.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/403369.html
create table temp_dp_id_ent_info as select min(id) as id from dianping_deal_business group by deal_id,business_id having count(1)>1;
create table temp_dp_deal_id_ent_info as select deal_id from dianping_deal_business group by deal_id,business_id having count(1)>1;


delete from dianping_deal_business
where deal_id in (select deal_id from temp_dp_id_ent_info)
and id not in (select id from temp_dp_id_ent_info);

drop table temp_dp_id_ent_info;
drop table temp_dp_deal_id_ent_info;



]]>
POI讀寫EXcelhttp://www.aygfsteel.com/luyongfa/archive/2013/08/22/403180.htmlMr.luMr.luThu, 22 Aug 2013 06:02:00 GMThttp://www.aygfsteel.com/luyongfa/archive/2013/08/22/403180.htmlhttp://www.aygfsteel.com/luyongfa/comments/403180.htmlhttp://www.aygfsteel.com/luyongfa/archive/2013/08/22/403180.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/403180.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/403180.htmlpackage com.wo116114.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class TestReadAndWrite {
 public static void main(String[] args) throws IOException {
  String path = "D:/dianping/gather/";
  String fileName = "result";
  String fileType = "xlsx";
   writer(path, fileName, fileType);
  
  read(path, fileName, fileType);
 }

 private static void writer(String path, String fileName, String fileType)
   throws IOException {
  InputStream stream = new FileInputStream(path + fileName + "."
    + fileType);
  // 創(chuàng)建工作文檔對(duì)象
  Workbook wb = null;
  if (fileType.equals("xls")) {
   wb = new HSSFWorkbook(stream);
  } else if (fileType.equals("xlsx")) {
   wb = new XSSFWorkbook(stream);
  } else {
   System.out.println("您的文檔格式不正確!");
  }
  // 創(chuàng)建sheet對(duì)象
  Sheet sheet1 = (Sheet) wb.getSheetAt(0);
  // 循環(huán)寫入行數(shù)據(jù)
   int num = sheet1.getLastRowNum() + 1;
  for (int i = 0; i < 5; i++) {
   Row row = (Row) sheet1.createRow(num+i);
   // 循環(huán)寫入列數(shù)據(jù)
   for (int j = 0; j < 8; j++) {
    Cell cell = row.createCell(j);
    cell.setCellValue("測試" + j);
   }
  }
  File file = new File(path + fileName + "." + fileType);
  FileOutputStream fileOut = new FileOutputStream(file);
  wb.write(fileOut);
  fileOut.close();
  stream.close();
 }

 public static void read(String path, String fileName, String fileType)
   throws IOException {
  InputStream stream = new FileInputStream(path + fileName + "."
    + fileType);
  Workbook wb = null;
  if (fileType.equals("xls")) {
   wb = new HSSFWorkbook(stream);
  } else if (fileType.equals("xlsx")) {
   wb = new XSSFWorkbook(stream);
  } else {
   System.out.println("您輸入的excel格式不正確");
  }
  Sheet sheet1 = wb.getSheetAt(0);
  for (Row row : sheet1) {
   for (Cell cell : row) {
    System.out.print(cell.getStringCellValue() + "  ");
   }
   System.out.println();
  }
 }
}



]]>
PostgreSQL數(shù)據(jù)庫切割和組合字段函數(shù)http://www.aygfsteel.com/luyongfa/archive/2013/05/15/399295.htmlMr.luMr.luWed, 15 May 2013 02:24:00 GMThttp://www.aygfsteel.com/luyongfa/archive/2013/05/15/399295.htmlhttp://www.aygfsteel.com/luyongfa/comments/399295.htmlhttp://www.aygfsteel.com/luyongfa/archive/2013/05/15/399295.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/399295.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/399295.html1.concat
a.介紹
concat(str "any" [, str "any" [, ...]])

Concatenate all but first arguments with separators.
The first parameter is used as a separator. 
NULL arguments are ignored.
b.實(shí)際例子:
postgres=# create table t_kenyon(id int,name varchar(10),remark text);
CREATE TABLE
postgres=# insert into t_kenyon values(1,'test','kenyon'),(2,'just','china'),(3,'iam','lovingU');
INSERT 0 3
postgres=# insert into t_kenyon values(4,'test',null);
INSERT 0 1
postgres=# insert into t_kenyon values(5,null,'adele');
INSERT 0 1
postgres=# select * from t_kenyon;
 id | name | remark  
----+------+---------
  1 | test | kenyon
  2 | just | china
  3 | iam  | lovingU
  4 | test | 
  5 |      | adele
(5 rows)

postgres=# select concat(id,name,remark) from t_kenyon;
   concat    
-------------
 1testkenyon
 2justchina
 3iamlovingU
 4test
 5adele
(5 rows)
c.說明 concat函數(shù)純粹是一個(gè)拼接函數(shù),可以忽略null值拼接,拼接的值沒有分隔符,如果需要分割符,則需要用下面的函數(shù)concat_ws。

2.concat_ws
a.介紹
concat_ws(sep text, str "any" [, str "any" [,...] ])

Concatenate all but first arguments with separators.
The first parameter is used as a separator.
NULL arguments are ignored.
b.實(shí)際應(yīng)用
postgres=# select concat_ws(',',id,name,remark) from t_kenyon;
   concat_ws   
---------------
 1,test,kenyon
 2,just,china
 3,iam,lovingU
 4,test
 5,adele
(5 rows)

postgres=# select concat_ws('_',id,name,remark) from t_kenyon;
   concat_ws   
---------------
 1_test_kenyon
 2_just_china
 3_iam_lovingU
 4_test
 5_adele
(5 rows)

postgres=# select concat_ws('',id,name,remark) from t_kenyon;
  concat_ws  
-------------
 1testkenyon
 2justchina
 3iamlovingU
 4test
 5adele
(5 rows)

postgres=# select concat_ws('^_*',id,name,remark) from t_kenyon;
     concat_ws     
-------------------
 1^_*test^_*kenyon
 2^_*just^_*china
 3^_*iam^_*lovingU
 4^_*test
 5^_*adele
(5 rows)
c.說明 concat_ws函數(shù)比concat函數(shù)多了分隔符的功能,其實(shí)就是concat的升級(jí)版,假如分隔符為'',則取出來的結(jié)果和concat是一樣的。其功能與mysql中的group_concat函數(shù)比較類似,但也有不同,pg中concat_ws分隔符還支持多個(gè)字符作為分隔符的,日常用得更多的可能是||。 

二、切割函數(shù)
1.split_part
a.介紹
split_part(string text, delimiter text, field int)

Split string on delimiter and return the given field (counting from one)
b.實(shí)際例子
postgres=# select split_part('abc~@~def~@~ghi','~@~', 2);
 split_part 
------------
 def
(1 row)

postgres=# select split_part('now|year|month','|',3);
 split_part 
------------
 month
(1 row)
c.說明 該函數(shù)對(duì)按分隔符去取某個(gè)特定位置上的值非常有效果

2.regexp_split_to_table
a.介紹
regexp_split_to_table(string text, pattern text [, flags text])

Split string using a POSIX regular expression as the delimiter.
b.使用例子
postgres=# SELECT regexp_split_to_table('kenyon,love,,china,!',',');
 regexp_split_to_table 
-----------------------
 kenyon
 love
 
 china
 !
(5 rows)

--按分割符切割
postgres=# SELECT regexp_split_to_table('kenyon,china,loves',',');
 regexp_split_to_table 
-----------------------
 kenyon
 china
 loves
(3 rows)

--按字母切割
postgres=# SELECT regexp_split_to_table('kenyon,,china',E'\\s*');
 regexp_split_to_table 
-----------------------
 k
 e
 n
 y
 o
 n
 ,
 ,
 c
 h
 i
 n
 a
(13 rows)
3.regexp_split_to_array
a.介紹
regexp_split_to_array(string text, pattern text [, flags text ])

Split string using a POSIX regular expression as the delimiter.
b.實(shí)際例子
postgres=# SELECT regexp_split_to_array('kenyon,love,,china,!',',');
  regexp_split_to_array   
--------------------------
 {kenyon,love,"",china,!}
(1 row)

postgres=# SELECT regexp_split_to_array('kenyon,love,,china!','s*');
             regexp_split_to_array             
-----------------------------------------------
 {k,e,n,y,o,n,",",l,o,v,e,",",",",c,h,i,n,a,!}
(1 row)
c.說明
上面用到的flag里的s*表示split all

]]>
將私有的jar包導(dǎo)入到maven本地庫http://www.aygfsteel.com/luyongfa/archive/2013/04/26/398425.htmlMr.luMr.luFri, 26 Apr 2013 03:15:00 GMThttp://www.aygfsteel.com/luyongfa/archive/2013/04/26/398425.htmlhttp://www.aygfsteel.com/luyongfa/comments/398425.htmlhttp://www.aygfsteel.com/luyongfa/archive/2013/04/26/398425.html#Feedback0http://www.aygfsteel.com/luyongfa/comments/commentRss/398425.htmlhttp://www.aygfsteel.com/luyongfa/services/trackbacks/398425.html將私有的jar包或者maven(http://maven.apache.org)找不到匹配的jar包,導(dǎo)入到本地庫中

 

mvn install:install-file -Dfile=d:/Downloads/apache-activemq-5.5.0/lib/activemq-core-5.5.0.jar -DgroupId=org.apache.activemq -DartifactId=activemq-core -Dversion=5.5.0 -Dpackaging=jar

 

 

解析:

mvn install:install-file  -Dfile=外部包的路徑 /  

                 -DgroupId=外部包的groupId /  

                 -DartifactId=外部包的artifactId /  

                 -Dversion=外部包的版本號(hào) /  

                 -Dpackaging=jar



]]>
主站蜘蛛池模板: 海阳市| 延川县| 汉源县| 沙洋县| 霍山县| 马关县| 旺苍县| 灵璧县| 双桥区| 司法| 华安县| 许昌市| 清镇市| 娄底市| 应城市| 广饶县| 休宁县| 密山市| 瑞昌市| 乡宁县| 教育| 防城港市| 紫阳县| 靖安县| 孟连| 佛冈县| 张家港市| 余姚市| 宜良县| 二连浩特市| 巴林右旗| 高雄市| 磐安县| 祁阳县| 孟村| 邯郸市| 富阳市| 建德市| 丰城市| 张家港市| 宜宾市|