반응형
driverClassName : JDBC 드라이버 패키지명을 포함한 완전한 클래스명
url : 데이터 베이스에 필요한 JDBC URL
initialSize : 풀이 시작될 때 생성할 커넥션 수
maxActive : 풀에서 동시에 제공하는 최대 커넥션 수
maxIdl : 동시에 휴먼 상태로 유지도리 수 있는 최대 커넥션 수

  1. <bean id="defaultHubDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
  2.         <property name="driverClassName" value="org.hsqldb.jdbcDriver"></property>
  3.         <property name="url" value="jdbc:hsqldb:hsql://localhost/roadrantz/roadrantz"></property>
  4.         <property name="username" value="username"></property>
  5.         <property name="password" value="pw"></property>
  6.         <property name="maxActive" value="80"></property>
  7.         <property name="maxIdle" value="50"></property>
  8. </bean>


728x90
반응형
반응형
[abc] : a, b or c
괄호안에 있는 문자가 존재하면 true(연결된것은 안됨)
  1. public class Test {
  2.     public static void main(String[] args) {
  3.             Pattern pattern      = Pattern.compile("[ABCD]");
  4.         Matcher matcher = pattern.matcher("A");
  5.         System.out.println(matcher.matches());
  6.     }
  7. }
결과 : true 
if문 쓰는것보다 훨씬 유용한것 같다.  


728x90
반응형
반응형


Preferences 설정 한방이면 끝!!!!
728x90
반응형
반응형
  1. @Aspect   // aspect 선언
  2. public class Audience {
  3.     @Pointcut("execution(* *.perform(..))") // pointcut 정의
  4.     public void performance(){}
  5.    
  6.     @Before("performance()")
  7.     public void takeSeats(){
  8.    
  9.     }
  10.    
  11.     @AfterReturning("performance()")
  12.     public void applaud(){
  13.        
  14.     }
  15.    
  16.     @AfterThrowing("performance()")
  17.     public void demandRefund(){
  18.        
  19.     }
  20. }
@AspectJ 기반의 빈을 애스펙트로 변환하는 방법을 알고 있는 오토프록시 빈 선언
AnnotationAwareAspectJAutoProxyCreator  -> 이름이 길다 -_-;
대신
<aop:aspectj-autoproxy /> 
이거 한방이면 끝.

대신 이걸 사용하기 위해서는
xmlns:aop="http://www.springframework.org/schema/aop"
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"
이거 추가해야함!! 


728x90
반응형
반응형
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" />

이렇게 선언해놓으면 ProxyFactoryBean을 따로 선언해줄 필요가 없다.

DefaultAdvisorAutoProxyCreator를 선언하면 스프링 컨테이너는 이빈을 BeanPostProcessor로 인식한다.
bean에 id가 없는건 이 빈을 참조해서 사용할 필요가 없기 때문이다.

(참고)----------
Application Context 내에 bean lifecycle

인스턴스화 -> property 할당 -> BeannameAware의 setBeanName() -> BeanFactoryAware의 setBeanFactory()
->ApplicationContextAware의 setApplicationContext()
-> BeanPostProcessor의 postProcessBeforeInitialization()
-> InitializingBean의 afterPropertiesSet() -> 커스텀 초기화 메서드 호출 
-> BeanPostProcessor의 postProcessAfterInitialization()...

위에서 말한 BeanPostProcessor로 인식한다는 말은 위에 적힌 lifeCycle에서 BeanPostPrecessor 로딩시 자동으로 bean을 생성한다는 말인것 같다. 

 
728x90
반응형
반응형
  1. <bean id="audienceAdvisor" class="org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor">
  2.     <prorperty name="advice" ref="audienceAdvice"></prorperty>
  3.     <prorperty name="expression" value="execution(* *.perform(..))"></prorperty>
  4. </bean>

excution(* *.perform(..))


excution  : method가 실행될때
*            : 모든 반환 값 타입에 대해
*.           : 모든 클래스의
perform   : perform() method
(..)         : 인자의 개수에 상관없이 


728x90
반응형
반응형
포인트컷은 어드바이스가 적용돼야할 메서드를 골라내는것

pointcut 정의
  1. <bean id="performancePointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut">
  2.     <prorperty name="pattern" value=".*perform">
  3. </prorperty></bean>
advice와 pointcut 결합
  1. <bean id="audienceAdvisor" class="org.springframework.aop.support.DefaultPointcutAdvisor">
  2.     <prorperty name="advice" ref="audienceAdvice">
  3.     <prorperty name="pointcut" ref="performancePointcut">
  4. </prorperty></prorperty></bean>
하나의 빈 설정으로 pointcut과 advice 동시정의
  1. <bean id="audienceAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
  2.     <prorperty name="advice" ref="audienceAdvice">
  3.     <prorperty name="pointcut" ref=".*perform">
  4. </prorperty></prorperty></bean>


728x90
반응형
반응형

정수 n에서 시작해 n이 짝수면 2로 나누고 홀수면 3을 곱한 다음 1을 더한다.
이렇게 해서 새로 만들어진 숫자를 n으로 놓고 n=1이 될때까지 같은 작업을 반복한다.
1이 나올때까지 만들어진 수의 개수(1포함)를 n의 사이클 길이라고 한다.

22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1
22의 사이클은 16


입력 
- 입력은 일련의 정수 쌍 i와 j로 구성되며 한 줄에 한쌍의 수가 입력된다. 모든 정수는 1,000,000보다 작고 0보다 크다

출력
- i, j를 입력된 순서대로 출력
- i, j의 최대 사이클 길이 출력 

입력 예          출력 예
1  10            1 10 20
100 200       100 200 125
210 210        201 210 89 

풀이) 풀긴 했는데  http://www.programming-challenges.com 들어가서 돌려보면 계속 틀렸다고 나온다 -_-;;젠장 . 뭐가 문제야

  1. import java.io.*;
  2.  
  3. class Main implements Runnable{
  4.     static String ReadLn(int maxLength){  // utility function to read from stdin,
  5.                                           // Provided by Programming-challenges, edit for style only
  6.         byte line[] = new byte [maxLength];
  7.         int length = 0;
  8.         int input = -1;
  9.         try{
  10.             while (length < maxLength){//Read untill maxlength
  11.                 input = System.in.read();
  12.                 if ((input < 0) || (input == ' ')) break//or untill end of line ninput
  13.                 line [length++] += input;
  14.             }
  15.  
  16.             if ((input < 0) && (length == 0)) return null;  // eof
  17.             return new String(line, 0, length);
  18.         }catch (IOException e){
  19.             return null;
  20.         }
  21.     }
  22.  
  23.     public static void main(String args[])  // entry point from OS
  24.     {
  25.         Main myWork = new Main();  // Construct the bootloader
  26.         myWork.run();            // execute
  27.     }
  28.  
  29.     public void run() {
  30.         new MyStuff().run();
  31.     }
  32. }
  33.  
  34. class MyStuff implements Runnable{
  35.     public void run(){
  36.             String input = (Main.ReadLn(20));
  37.             calcCycle(input);       
  38.     }
  39.    
  40.     // You can insert more classes here if you want.
  41.    
  42.     public void calcCycle(String input){
  43.         String[] inputArray     = input.trim().split(" ");
  44.         int startInput    = Integer.parseInt(inputArray[0]);
  45.         int endInput          = Integer.parseInt(inputArray[1]);
  46.         int maxCount            = 0;
  47.         int maxNumber         = 0;
  48.        
  49.         if (startInput > endInput){
  50.             int temp    = endInput;
  51.             endInput        = startInput;
  52.             startInput  = temp;
  53.         }
  54.                
  55.         while(startInput <= endInput){    
  56.             int count      = 1;             
  57.             int number   = startInput;
  58.            
  59.             if (number != 1){
  60.                 while (number > 1){
  61.                     if (number % 2 == 0){
  62.                         number = number /2;
  63.                     }else {        
  64.                         number = number * 3 + 1;           
  65.                     }
  66.                     count++;
  67.                 }             
  68.             }
  69.  
  70.             if (maxCount < count){
  71.                 maxCount    = count;
  72.             }
  73.             startInput++;
  74.         }
  75.  
  76.         System.out.println( inputArray[0] + " " + inputArray[1] + " " + maxCount);
  77.     }
  78.    
  79. }


728x90
반응형

'Development > Algorithm' 카테고리의 다른 글

에라토스테네스의 체  (0) 2016.12.07
[Try-catch]대문자 출력  (0) 2013.11.04
[Programing Challenges]반전한 수 더하기  (0) 2013.02.12
[Hacker Cup]Find the Min  (0) 2013.02.01
[Hacker Cup]Balanced Smileys  (0) 2013.01.31
반응형
DB : Oarcle

SELECT A.TABLE_NAME as 테이블명
     , B.COMMENTS as 테이블한글명
     , A.COLUMN_NAME as 컬럼명
     , C.COMMENTS as 컬럼한글명
     , A.DATA_LENGTH
     , A.DATA_TYPE     
     , A.NULLABLE
     , D.CONSTRAINT_NAME
     , D.CONSTRAINT_TYPE
FROM   ALL_TAB_COLUMNS A
, ALL_TAB_COMMENTS B
     , ALL_COL_COMMENTS C
     , ALL_CONSTRAINTS  D
WHERE  A.TABLE_NAME = B.TABLE_NAME
  AND  A.TABLE_NAME = C.TABLE_NAME
  AND  A.TABLE_NAME = D.TABLE_NAME
  AND  A.COLUMN_NAME = C.COLUMN_NAME
  AND  A.TABLE_NAME = :tableNm

CONSTRAINT_TYPE 을 'P' 로 설정해주면 입력한 테이블의 PK만 조회 가능하다. !

 
  
728x90
반응형

+ Recent posts