[완료] mybatis 의 DB 연결 폴 생성 시점을 알고 싶습니다.

emptynote의 이미지

이곳 kldp 에서 mybatis 설정파일 reload 에 대해서 질문을 해서 Fe.head 님께서 알려주셨는데,

그 방법은 "JDK 1.5 이상, Spring, mybatis, spring-mybatis 라이브러리가 설치되어 있는 환경에서만 된다." 라고 하네요.

spring 에서 돌아가는것이 아니기때문에 소스를 이용할 수가 없네요.

힘들게 비지니스 로직 재 로딩을 구현해서 서버 중지 없는 개발 첫발을 내 밀었는데 환장하겠네요.

현재 제 상태에서 가장 좋은 mybatis 설정파일 reload 해결책은

Lifecycle 에서 SqlSessionFactory 에 대해서 권장하는 싱글턴이 아닌 설정파일과 mapper 파일들 변경시 다시 생성하는건데요.

아래 mybatis 샘플 예제에서 mybatis 의 DB 연결 폴 생성 시점을 알려 주시면,

설정파일과 mapper 파일들 변경시 다시 생성할지 결정을 하는데 도움이 될것 같습니다.

factory = new SqlSessionFactoryBuilder().build(is);

이 문장 1000번 수행해도 db 서버 연결은 일어나지를 않네요.

폴 생성 시점과 실제 DB 연결 시점이 다를 수 있기에 이것만으로는 DB pool 을 생성하지 않았다고 판단할 수 없네요.

정말로 어디에서 DB 폴을 생성하는걸까요?

소스를 봐도 마음이 급해서인지 눈에 잘 안들어 오네요.

dbcp 로 회귀를 해야 하는가 아직도 결정을 못하고 있네요.

----- mybatis 샘플 예제

InputStream is = Resources.getResourceAsStream(res);
SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(is);            
 
SqlSession session = factory.openSession();
 
List<MembersVo> list = session.selectList("getlist");

----------- mybatis - Scope and Lifecycle 관련 글
참고 주소 : http://mybatis.github.io/mybatis-3/getting-started.html
SqlSessionFactory

Once created, the SqlSessionFactory should exist for the duration of your application execution. There should be little or no reason to ever dispose of it or recreate it. It's a best practice to not rebuild the SqlSessionFactory multiple times in an application run. Doing so should be considered a “bad smell”. Therefore the best scope of SqlSessionFactory is application scope. This can be achieved a number of ways. The simplest is to use a Singleton pattern or Static Singleton pattern.

Fe.head의 이미지

이 사이트 보다는 okjsp.net 사이트나 저번 링크에 걸린 문서가 있는 사이트에 질문을 받아보시는 것이
좋을 듯 싶습니다.

고작 블로킹 하나, 고작 25점 중에 1점, 고작 부활동
"만약 그 순간이 온다면 그때가 네가 배구에 빠지는 순간이야"

emptynote의 이미지

자문 자답 합니다.

생성할때 마다 연결 폴을 생성하네요.

테스트할때 없다고 한것은 연결이 사용할때 추가되기때문에

아무런 사용을 안한 상태에서 측정했기때문입니다.

그리고 이제 부터는 이곳 보다 okjsp 에 많이 물어 볼려구 합니다.

답변 감사합니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.