jsp db connection 설정 (datasource)
라이브러리
1 | commons-collections4-4.1.jar |
4개 파일 다운 후 WebContent/WEB-INF/lib
에 복사
mysql connector는
프로젝트 web.xml 생성
프로젝트 우클릭 - Java EE Tools - Generate Deployment Descriptor Stub -> WebContent/WEB-INF/web.xml
생성 확인
아래 내용 추가
1 | <!-- web.xml --> |
톰캣 서버 context.xml 설정
1 | <!-- context.xml --> |
dao 생성자
1 | import java.sql.SQLException; |
주의사항
mysql connector는 소스쪽과 서버쪽 폴더 동시에 적용시켜야한다.(복사)
- 위와 같이 했음에도 아래와 같이 에러가 나는 경우
- 심각: Servlet.service() for servlet [com.javalec.ex.frontcontroller.BFrontContrller] in context with path [/first_test] threw exception [Servlet execution threw an exception] with root cause
- 위에설치한 4개의jar파일중 버전이 맞지 않아서 생기는 에러(ex. mysql-connector-java-5.1.44-bin.jar이 낮아서 생기는 에러였음)
- 최신버전으로 다운로드 후 다시 WebContent/WEB-INF/lib에 복사
- 아파치 톰캣 설치한 경로에도 mysql-connector jar파일을 복사해주어야 한다.
jsp db connection 설정 (datasource)
https://hwiveloper.github.io/2017/10/10/java-jdbc-db-connection-datasource/
You need to set
install_url
to use ShareThis. Please set it in _config.yml
.