티스토리 뷰
1. JDBC 드라이버 설치
2. ConnectionPool 기능 관련 jar 파일 /WEB-INF/lib에 설치
3. 톰캣 서버 설정 파일인 context.xml 파일 수정
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--><!-- The contents of this file will be loaded for each web application --><Context>
<!-- Default set of monitored resources. If one of these changes, the -->
<!-- web application will be reloaded. -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<Resource
name="jdbc/oracle"
auth="Container"
type="javax.sql.DataSource"
dirverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:xe"
username="root"
password="1234"
maxActive="50"
maxWait="-1"/>
</Context>
|
cs |
4. 사용법
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
private Connection con;
private PreparedStatement ps;
private DataSource dataFactory;
try {
Context ctx = new InitialContext();
Context envContext = (Context) ctx.lookup("java:/comp/env");
dataFactory = (DataSource) envContext.lookup("jdbc/oracle");
}catch(Exception e) {
e.printStackTrace();
}
try {
con = dataFactory.getConnection();
String query = "select * from table1";
ps = con.prepareStatement(query);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
String col = rs.getString("col");
}
rs.close();
ps.close();
con.close();
} catch (Exception e) {
e.printStackTrace();
}
|
cs |
'Seek > Spring' 카테고리의 다른 글
Annotation 종류 및 기능 (0) | 2019.05.10 |
---|---|
내장 객체들의 스코프 (0) | 2019.04.17 |
Session 특징 및 사용 방법 (0) | 2019.04.16 |
Cookie 특징 및 사용 방법 (0) | 2019.04.16 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- project facet
- @Controller
- DP
- java version
- session-timeout
- angular
- 내장 객체
- @RequestMapping
- baekjoon
- Persistence
- Project facet Java version
- java
- SESSION
- @ModelAttribute
- python3
- Server runtime environment
- @Component
- ConnectionPool
- 스택
- 다이나믹 프로그램
- @Repository
- @Autowired
- Project facet Java version 10 is not supported
- 다이나믹 프로그래밍
- not supported
- 그리디
- @RequestParam
- @Service
- tomcat
- Stack
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
글 보관함