2012년 2월 20일 월요일

Preventing database connection pool leaks

Preventing database connection pool leaks

http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html


A database connection pool creates and manages a pool of connections to a database. Recycling and reusing already existing connections to a database is more efficient than opening a new connection.
There is one problem with connection pooling. A web application has to explicitly close ResultSet's, Statement's, and Connection's. Failure of a web application to close these resources can result in them never being available again for reuse, a database connection pool "leak". This can eventually result in your web application database connections failing if there are no more available connections.
There is a solution to this problem. The Apache Commons DBCP can be configured to track and recover these abandoned database connections. Not only can it recover them, but also generate a stack trace for the code which opened these resources and never closed them.
To configure a DBCP DataSource so that abandoned database connections are removed and recycled add the following attribute to the Resource configuration for your DBCP DataSource:
removeAbandoned="true"
When available database connections run low DBCP will recover and recycle any abandoned database connections it finds. The default is false.
Use the removeAbandonedTimeout attribute to set the number of seconds a database connection has been idle before it is considered abandoned.
removeAbandonedTimeout="60"
The default timeout for removing abandoned connections is 300 seconds.
The logAbandoned attribute can be set to true if you want DBCP to log a stack trace of the code which abandoned the database connection resources.
logAbandoned="true"
The default is false.



POJO class sample.
-------------------------------------------
BasicDataSource bds = new BasicDataSource();
..
DB설정 부분..
..
..
아래 내용 추가.

bds.setRemoveAbandoned( true );
bds.setRemoveAbandonedTimeout( 60 );
bds.setLogAbandoned( true ); 

2012년 2월 14일 화요일

JAVA CLOSE_WAIT 관련 내용


JAVA CLOSE_WAIT 이슈는 자바의 버그에서 비롯된 것으로 판단됨.

관련 버그 내용.

bug: 6215050 java classes_nio (so) SocketChannel created in CLOSE_WAIT and never cleaned up.. File Descriptor leak
http://www.oracle.com/technetwork/java/javase/releasenotes-142123.html

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6215050


이와 관련한 내용 및 문제제기 관련 사이트 (해결방법은 아니므로 참고만 하세요.)
http://stackoverflow.com/questions/8326058/how-to-kill-tcp-connection-with-close-wait-state

https://forums.oracle.com/forums/thread.jspa?threadID=1160014

http://tux.hk/index.php?m=05&y=09&entry=entry090521-111844


http://www.thatisjava.com/java-core-apis/35975/

Push Notification 관련 정보 모음(작업중)


MQTT 를 이용한 tokudu
http://tokudu.com/2010/how-to-implement-push-notifications-for-android/


Push 서버 샘플
http://translate.googleusercontent.com/translate_c?hl=ko&langpair=en%7Cko&rurl=translate.google.co.kr&twu=1&u=http://tokudu.com/2010/how-to-implement-push-notifications-for-android/&usg=ALkJrhhmByybxQBUAMl9KHmjgPI7C1CXEw


클라이언트 연결유지 샘플
http://translate.googleusercontent.com/translate_c?hl=ko&langpair=en%7Cko&rurl=translate.google.co.kr&twu=1&u=http://devtcg.blogspot.com/2009/01/push-services-implementing-persistent.html&usg=ALkJrhgRnSh33X2R5mo63HjSkzIBl4yhAA



[팁] Notification 을 이용한 실행시 Activity 중복 실행 막기
http://www.androidpub.com/index.php?mid=android_dev_info&category=127161&page=2&document_srl=796480

chkrootkit 사용

설치는 yum 또는 wget 을 이용하면 간편..

[root@test]#yum install chkrootkit

yum이 없을때는 wget 으로 다운로드.. 또는 사이트에서 직접 받아야겠지요.


[root@test root]#wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz

[root@test root]# tar zxvf chkrootkit.tar.gz

[root@test root]# cd chkrootkit-0.49

[root@test chkrootkit-0.49]# make sense


이후 실행하면 된다.

Oracle *.trc 파일정리


Oracle trc 파일정리: 7일이상 지난 파일들을 찾아서 삭제

find /opt/oracle/admin/TEST/bdump \( -ctime +7 -name '*.trc' \) -exec rm -f {} \;
find /opt/oracle/admin/TEST/udump \( -ctime +7 -name '*.trc' \) -exec rm -f {} \;


위 내용을 스크립트로 만들어서 crontab 에 등록해서 쓰면 좋겠지.

00 02 * * * oracle_log_del.sh

매일 새벽2시에 정리..

2012년 1월 9일 월요일

Nakkomsu: 문재인 "박근혜 꺾을 수 있는 사람" 질문에 김제동 "문재인"

Nakkomsu: 문재인 "박근혜 꺾을 수 있는 사람" 질문에 김제동 "문재인": 문재인 노무현 재단 이사장과 SBS '힐링캠프' MC 김제동이 차기 대권 주자에 대한 생각을 짧게 주고받았다. 9일 문재인 노무현 재단 이사장이 SBS '힐링캠프'에 출연했다. 문 이사장은 이날 방송에서 주제를 보고 문제를 내는 스피드 퀴즈에...

2011년 7월 18일 월요일

안드로이드(Android) SecurePhoto (비밀포토), 중요한 사진을 암호화해서 보호하세요.

SecurePhoto가 Phandroid.com 에 소개되었습니다.
http://phandroid.com/2011/07/20/apps-of-the-day-falling-fred-securephoto/


내 스마트폰의 중요한 사진들을 어떻게 보관하세요?


신분증사진, 인터넷뱅킹 보안카드, 문서사진, 
미처 메모하지 못한 회의록, 
그리고 사생활이 담긴 소중한 사진, 
지울수는 없지만 남이 보면 안되는 사진들..


SecurePhoto는 이런 사진들을 설정한 비밀번호를 이용하여, 이미지파일 자체를 암호화하여 보관합니다.


즉, 다른 뷰어에서 못보게 감추는것이 아니라, 암호화된 새로운 파일로 만들어 보관하는것 입니다.


암호화된 파일은 다른 뷰어로는 볼 수 없고, 오직 SecurePhoto를 이용하여 설정한 비밀번호를 입력해야만 볼 수 있습니다.
물론, 암호파일을 원래의 사진파일로 복원도 가능합니다.


중요한 사진들을 암호화하면 도용이나 폰의 분실, 도난시에도 사생활 및 개인정보가 유출될 위험을 줄일 수 있습니다.




* 중요: 비밀번호는 스마트폰 내부에 따로 저장되지 않으므로, 잊지 않도록 잘 기억해야 합니다.

* 간혹 비밀번호가 생각나지 않으신다고 복원하는 방법을 묻는 분들이 계십니다. 설정한 비밀번호를 가지고 사진파일 자체를 암호화해서 전혀 다른형태의 보안파일로 만들기때문에, 안타깝게도 비밀번호를 모르면 복원할 수 있는 방법이 없습니다.

* 비밀번호가 너무많아서 기억하기 어려우시다면, 비밀메모(SecureMemo)를 활용해보시는것은 어떨까요?





1. 암호화된 사진파일들의 목록







2. 한글은 초성검색도 가능합니다.





3. 각 파일들의 성격에 따라 분류할 수 있습니다.(아이콘)





4. 암호화된 사진을 보기 위해서는 설정한 비밀번호를 입력해야 합니다.





5. 암호화된 사진을 원래대로 되돌리거나, 비밀번호를 변경하고, 필요없는 파일의 삭제도 가능합니다. 물론, 비밀번호가 일치해야겠지요.





6. 자주쓰는 사진파일들은 위젯으로 바탕화면에 꺼내놓고 편리하게 쓸 수 있습니다.











SecurePhoto (비밀포토) 다운로드(안드로이드 마켓)






* 또 다른 암호 어플리케이션, 비밀메모는 아래에서 확인하세요.
SecureMemo (비밀메모) 다운로드(안드로이드 마켓)

사용기(심파일 리뷰)
http://simfile.webhard.co.kr/mobile/view.html?cat=624&fnum=293782&list=title&num=30&retUrl=%2Fmobile%2Flist.html%3Fcat%3D624