connection pool 설정 변경

application.properties에서 지정할 수 있다..


default는 org.apache.tomcat.jdbc.pool.DataSource 이다.


#spring.datasource.type = org.apache.tomcat.jdbc.pool.DataSource

#spring.datasource.type = com.zaxxer.hikari.HikariDataSource

#spring.datasource.type = org.apache.commons.dbcp.BasicDataSource

#spring.datasource.type = org.apache.commons.dbcp2.BasicDataSource

#spring.datasource.type = com.mchange.v2.c3p0.ComboPooledDataSource

#spring.datasource.type = com.jolbox.bonecp.BoneCPDataSource


Posted by 무세1
,

spring + mybatis 프로젝트 구성


src/main/java 폴더에 mapper.xml 파일을 위치 시키니 maven build mapper.xml 파일이 누락되는 현상이 발생함.


src/main/resources 폴더에 mapper.xml 파일을 옮긴 후에 빌드하니 정상적으로 됨.

'java' 카테고리의 다른 글

java.sql.SQLRecoverableException: IO Error: Connection reset 오류 해결  (0) 2015.11.30
springboot connection pool 설정  (0) 2015.10.22
spring mysql datasouce  (0) 2015.02.08
쓰레드.. wait, notify, notifyAll  (0) 2014.07.09
Thread join 함수  (0) 2014.07.09
Posted by 무세1
,

spring mysql datasouce

java 2015. 2. 8. 17:35

mysql> create user testuser;

Query OK, 0 rows affected (0.00 sec)


mysql> create user testuser@localhost identified by 'testuser';

Query OK, 0 rows affected (0.00 sec)


mysql> create schema test default character set utf8;

Query OK, 1 row affected (0.00 sec)


mysql> select host, user, password from user;

+-----------------------+----------+-------------------------------------------+

| host                  | user     | password                                  |

+-----------------------+----------+-------------------------------------------+

| localhost             | root     |                                           |

| skp1002428mn001.local | root     |                                           |

| 127.0.0.1             | root     |                                           |

| ::1                   | root     |                                           |

| localhost             |          |                                           |

| skp1002428mn001.local |          |                                           |

| %                     | testuser |                                           |

| localhost             | testuser | *3A2EB9C80F7239A4DE3933AE266DB76A7846BCB8 |

+-----------------------+----------+-------------------------------------------+

8 rows in set (0.00 sec)


mysql> grant all privileges on test.* to testuser@localhost;

Query OK, 0 rows affected (0.00 sec)


mysql> grant select, insert, update, delete on test.* to testuser@localhost;

Query OK, 0 rows affected (0.01 sec)


mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)




mysql -utestuser -ptestuser



    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">  

        <property name="driverClassName" value="com.mysql.jdbc.Driver" />

        <property name="url" value="jdbc:mysql://localhost:3306/test" />

        <property name="username" value="testuser" />

        <property name="password" value="testuser" />

    </bean>



'java' 카테고리의 다른 글

springboot connection pool 설정  (0) 2015.10.22
maven build 할때 mapper.xml 누락되는 현상  (0) 2015.03.05
쓰레드.. wait, notify, notifyAll  (0) 2014.07.09
Thread join 함수  (0) 2014.07.09
Spring - IoC & DI & AOP ( 퍼옴 )  (0) 2014.07.03
Posted by 무세1
,

wait, notify, notifyAll함수는 Object클래스에서 구현된 메소드이다.

당연히 모든 클래스가 다 상속받는 메소드이기도 하다.
사용법은 현재 자신클래스를 공유해서 사용하는 경우, 어떤 조건에 따라 자기를 사용하는 쓰레드를 대기시킬 경우 wait를 사용하고 자신이 다시 사용가능하게 될 경우 notify 또는 notifyAll을 호출한다. notify는 자신을 사용하려고 대기하는 쓰레드 중 아무거나 한개를 깨우고 notifyAll은 자신을 사용하려고 대기하는 쓰레드를 모두 다 깨운다.

notifyAll을 사용할 경우 wait를 사용하는 메소드에서 while문으로 wait를 사용해야 한다.



참조..

http://gladtosee.tistory.com/191


'java' 카테고리의 다른 글

maven build 할때 mapper.xml 누락되는 현상  (0) 2015.03.05
spring mysql datasouce  (0) 2015.02.08
Thread join 함수  (0) 2014.07.09
Spring - IoC & DI & AOP ( 퍼옴 )  (0) 2014.07.03
java 예외(exception) 처리에 대한 괜찮은 글..  (0) 2014.06.26
Posted by 무세1
,

Thread join 함수

java 2014. 7. 9. 20:25

쓰레드 실행할때..  쓰레드가 끝날때까지 기다려 주는 join 함수가 있다..


public class Counter extends Thread {

int a;

int b;

int sum;

Counter(int x, int y) {

a=x;

b=y;

}

public void run() {

for(int i=a; i<=b; i++) {

sumsum+i;

}

}

int getSum() {

return sum;

}

}


public class test01 {


public static void main(String[] args) throws InterruptedException {

Counter at = new Counter(0, 100);

System.out.println(at.isAlive());

at.start();

System.out.println(at.isAlive());

at.join();

//Thread.sleep(1);

System.out.println(at.getSum());

System.out.println(at.isAlive());

}

}


결과는...

false

true

5050

false



'java' 카테고리의 다른 글

spring mysql datasouce  (0) 2015.02.08
쓰레드.. wait, notify, notifyAll  (0) 2014.07.09
Spring - IoC & DI & AOP ( 퍼옴 )  (0) 2014.07.03
java 예외(exception) 처리에 대한 괜찮은 글..  (0) 2014.06.26
lamda.. (업데이트중)  (0) 2014.05.21
Posted by 무세1
,

Spring IoC 와 DI에 관해서 잘 정리된 글..


http://isstory83.tistory.com/m/post/91



Spring AOP


http://isstory83.tistory.com/m/post/90


'java' 카테고리의 다른 글

쓰레드.. wait, notify, notifyAll  (0) 2014.07.09
Thread join 함수  (0) 2014.07.09
java 예외(exception) 처리에 대한 괜찮은 글..  (0) 2014.06.26
lamda.. (업데이트중)  (0) 2014.05.21
String, StringBuffer, StringBuilder 차이점..  (0) 2014.05.14
Posted by 무세1
,

요즘 한참 Exception 처리에 대해 고민 하던중.. 

좋은 글을 발견해서 링크한다...


Java 예외(Exception) 처리에 대한 작은 생각

http://www.nextree.co.kr/p3239/

'java' 카테고리의 다른 글

Thread join 함수  (0) 2014.07.09
Spring - IoC & DI & AOP ( 퍼옴 )  (0) 2014.07.03
lamda.. (업데이트중)  (0) 2014.05.21
String, StringBuffer, StringBuilder 차이점..  (0) 2014.05.14
java 현재시간과 시간 지연  (0) 2014.03.18
Posted by 무세1
,

lamda.. (업데이트중)

java 2014. 5. 21. 21:26

lamda 도입이유..

  - 핵심 코드가 변경되어도 호스트 코드의 수정을 최소화 시키고 간소화 시키기 위한 노력

  - 핵심 코드를 추상화 하여 유연하게 만들기 위한 노력


p -> p.getGender() == Person.Sex.MALE
    && p.getAge() >= 18
    && p.getAge() <= 25


p -> {
    return p.getGender() == Person.Sex.MALE
        && p.getAge() >= 18
        && p.getAge() <= 25;
}




함수형 인터페이스는 오직 하나의 추상 메서드(abstract method)를 갖는 인터페이스이다. 

(함수형 인터페이스는 한 개 이상의 기본 메서드(default methods)나 정적 메서드(static methods)를 포함할 수 있다.)

함수형 인터페이스는 오직 하나의 추상 메서드를 포함하기 때문에, 구현할 때 메서드 이름을 생략할 수 있다.

익명 클래스 식을 사용하는 대신에 람다식을 사용하여 메서드 호출 부분을 다음과 같이 처리할 수 있다.

Posted by 무세1
,

링크..


http://slipp.net/questions/271

'java' 카테고리의 다른 글

java 예외(exception) 처리에 대한 괜찮은 글..  (0) 2014.06.26
lamda.. (업데이트중)  (0) 2014.05.21
java 현재시간과 시간 지연  (0) 2014.03.18
ResultSet rowcount 구하기  (0) 2014.03.14
java 오늘일자 string format YYYYMMDD  (2) 2014.03.12
Posted by 무세1
,

java로 현재 시간 구할려면..  

System.currentTimeMillis   구한후에..

SimpleDateFormat 으로 원하는 포맷으로 출력하면 된다..


그리고 시간 지연 시키기 위해서는..

Robot이라는 클래스를 이용해서 지연 시킬 수 있다..


TimeDelayTest.java

import java.awt.AWTException;

import java.awt.Robot;

import java.text.SimpleDateFormat;

import java.util.Date;



public class TimeDelayTest {


    public static void main(String arg[]) {

        

        SimpleDateFormat dayTime = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");

        

        long start = System.currentTimeMillis() ; 

        System.out.println("start=" + dayTime.format(new Date(start)));

        

        //5초 지연

        DelayTime(5);

        

        long end = System.currentTimeMillis(); 

        System.out.println("end  =" + dayTime.format(new Date(end)));

        

        System.out.println((end-start)/1000 +"초지연");

        

    }

    

    public static void DelayTime(int delaySec) {

        

        Robot robot = null;

        try {

            robot = new Robot();

        } catch (AWTException e) {

        }

        robot.delay(delaySec * 1000);

        

    }


}


결과

start=2014-50-18 04:50:17

end  =2014-50-18 04:50:22

5초지연


Posted by 무세1
,