原创 LeetCode 028. Implement strStr()

Implement strStr()   Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 i

原创 LeetCode 027. Remove Element

Remove Element Given an array and a value, remove all instances of that value in place and return the new lengt

原创 使用Spring JDBC框架連接並操作數據庫

在前一篇博文JAVA通過JDBC連接並操作MySQL數據庫中,我們知道如何通過JDBC連接並操作數據庫,但是請看程序,整個程序連接數據庫和關閉數據庫佔了很大一部分代碼量,而且每次我們執行一下數據庫操作都得來這麼一大段重複代碼,這是很煩人的

原创 LeetCode 387. First Unique Character in a String

387. First Unique Character in a String Given a string, find the first non-repeating character in it and return

原创 linux tomcat7 配置證書(JKS和PKCS12格式)

1. 環境說明 系統:debian7 JDK版本:1.7 tomcat版本:7 2. 啓動tomcat7說明 apt-get install tomcat7之後,tomcat相關文件會被分配到兩個目錄:一個是/var/lib/tomcat

原创 獲取服務器出口ip

curl ip.cn curl http://members.3322.org/dyndns/getip curl http://ifconfig.me/ip

原创 LeetCode 014. Longest Common Prefix

Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings.

原创 使用Ibatis操作MySQL數據庫

iBatis 是apache 的一個開源項目,一個O/R Mapping 解決方案,iBatis 最大的特點就是小巧,上手很快。如果不需要太多複雜的功能,iBatis 是能夠滿足你的要求又足夠靈活的最簡單的解決方案,現在的iBatis 已

原创 spring-data-redis連接操作redis

Java連接redis的客戶端有很多,其中比較常用的是Jedis. (參考:redis client) spring-data-redis則是對Jedis進行了高度封裝,使用起來非常方便。下面就以代碼爲例說明spring-data-red

原创 Spring @Value註解失敗

Spring 版本 3.0.5.Release @Value註解有兩種形式: 1、@Value("${}") 如果只在application-context.xml中註冊配置文件: <bean id="propertyConfigure

原创 slowhttptest初體驗

源碼 由於google code關閉,目前已經在Google code上搜不到slowhttptest,我在github上搜到了下面這個。 源碼:https://github.com/shekyan/slowhttptest 編譯安裝參

原创 HttpClient javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated

最近在調用一些https的接口,然後採用的認證方式是用戶名+密碼。 這個時候調用接口則會提示httpclient未認證的錯誤,導致接口無法調用: HttpClient javax.net.ssl.SSLPeerUnverifiedExce

原创 rsyslog 接收遠程日誌且去掉日誌頭

最近碰到一個需求是要用syslog接收遠程日誌,將遠程日誌輸出到一個單獨的文件中。 實現這個需求,只需要在/etc/rsyslog.conf添加如下配置: $template IpTemplate,"/var/log/%FROMHOST

原创 hadoop 命令執行報錯解決

ls: Failed on local exception: java.io.IOException: javax.security.sasl.SaslException: GSS initiate failed [Caused by

原创 log4j.aditivity實現某類日誌只輸出到特定file

第一種需求:將log4j level高的輸出到一個特定的文件,以便查看。 下面展示一個log4j配置來實現這一功能 ### set log levels ### log4j.rootLogger = debug , stdout