Upload
trinhthu
View
338
Download
6
Embed Size (px)
Citation preview
TIBERO-WAS 연동 Guide 본 문서에서는 Tibero RDBMS 에서 제공하는 JDBC 통한 JEUS, WEBLOGIC 등 다양한 WAS (Web Application
Server) 제품과의 연동방법을 알아본다.
1
Tibero-WAS 연동 Guide
© 2011 Tibero Co., Ltd. All Rights Reserved.
1. Connection Pool 방식 ............................................................................................................... 2
2. JEUS 연동 .................................................................................................................................... 3
2.1. JEUSMain.xml 설정(Thin 방식) ............................................................................................................... 3
2.2. SAMPLE SOURCE(connect.jsp) ................................................................................................................ 4
3. TOMCAT 4.x 연동 ...................................................................................................................... 5
3.1. SERVER.xml 설정 ........................................................................................................................................... 5
3.2. WEB.xml 설정 ................................................................................................................................................. 6
3.3. SAMPLE SOURCE(connect.jsp) ................................................................................................................ 6
4. TOMCAT 5.5.x 연동 ................................................................................................................... 7
4.1. context.xml 설정 ........................................................................................................................................... 7
4.2. SAMPLE SOURCE(connect.jsp) ................................................................................................................ 8
5. WEBLOGIC 연동 ......................................................................................................................... 9
5.1. 콘솔 실행 후 JDBC 설정 .......................................................................................................................... 9
5.2. config.xml 설정.............................................................................................................................................. 9
6. JBOSS 연동 ............................................................................................................................... 10
6.1. JBOSS 설정 ................................................................................................................................................... 10
6.1.1. 설치 젂 환경 설정 ........................................................................................................................... 10
6.1.2. JDBC 파일 위치 ................................................................................................................................. 11
6.1.3. Tibero와의 연동 테스트 ................................................................................................................ 11
6.1.4. 서버에 해당 프로젝트 추가 하기 ............................................................................................. 13
6.1.5. JSP Test (Tibero) ................................................................................................................................ 14
Contents
Update History
Date Worker Comments
2011.03.11 박근용 문서서식업데이트
2009.10.20 류제만 문서업데이트
2
Tibero-WAS 연동 Guide
© 2011 Tibero Co., Ltd. All Rights Reserved.
1. Connection Pool 방식
Database와 연결된 connection을 미리 만들어서 pool속에 저장해 두고 있다가 필요할 때에
connection을 pool에서 가지고 와서 사용을 한 후 다시 pool에 반환을 하는 방법
1. Pool에서 Connection을 가져온다.
2. Connection을 사용한다.
3. Connection을 Pool에 반환한다.
Connection
Connection
Connection
Connection Connection
Pool
3
Tibero-WAS 연동 Guide
© 2011 Tibero Co., Ltd. All Rights Reserved.
2. JEUS 연동
2.1. JEUSMain.xml 설정(Thin 방식)
<data-source> <database> <vendor>other</vendor> //JEUS5 fix23이후 버젂은 <vender>tibero</vender>로 해주시기 바랍니다. <export-name>tibero</export-name>
<data-source-class-name>com.tmax.tibero.jdbc.ext.TbConnectionPoolDataSource </data-source-class-name> //classname <data-source-type>ConnectionPoolDataSource</data-source-type> <database-name>tibero</database-name> // Tibero 설치 SID <data-source-name>com.tmax.tibero.jdbc.ext.TbConnectionPoolDataSource </data-source-name> <port-number>8629</port-number> // Tibero 연결 사용 포트 <server-name>localhost</server-name> // Tibero 설치 주소 <user>tibero</user> // 사용 계정 <password>tmax</password> // 계정 Password <connection-pool>
<pooling> <min>10</min> <max>30</max> <step>4</step> <period>3600000</period>
</pooling> <wait-free-connection>
<enable-wait>false</enable-wait> <wait-time>10000</wait-time>
</wait-free-connection> <max-use-count>0</max-use-count> <dba-timeout>-1</dba-timeout> <stmt-caching-size>-1</stmt-caching-size> <stmt-fetch-size>-1</stmt-fetch-size>
</connection-pool> </database>
</data-source>
1) 설정을 하기 젂에 $TB_HOME/client/lib/jar 안에 들어있는 tibero-jdbc.jar 파일을
$JEUS_HOME/lib/datasource 경로로 복사를 해 넣어야 한다.
2) $JEUS_HOME/config/`hostname`/JEUSMain.xml 파일에서 환경 설정을 한다.
3) </node> 끝나는 지점 아래에 <resource>와 </resource>를 만들고 그 사이에 DB 관련
환경 설정을 넣으면 된다.
4) 설정이 완료가 되면 JEUS를 변경 내용을 적용하기 위하여 JEUS를 재부팅해야 한다.
* DB 설정이 정상적으로 이루어 졌는지에 대한 확인은 JEUS 5매뉴얼에서 dbpooladmin
명령어를 참조.(JEUS 6에서는 jeusadmin 명령어로 확인.)
4
Tibero-WAS 연동 Guide
© 2011 Tibero Co., Ltd. All Rights Reserved.
2.2. SAMPLE SOURCE(connect.jsp)
<%@ page import="java.sql.*" %> <%@ page import="javax.sql.*" %> <%@ page import="javax.naming.*" %> <% Connection con=null; Statement st=null; ResultSet rs=null;
try {
InitialContext initCtx = new InitialContext(); DataSource ds = (DataSource) initCtx.lookup("tibero"); //export-name과 일치 시킵니다.
con=ds.getConnection(); st=con.createStatement(); rs=st.executeQuery("select 'Success!!' from dual"); while(rs.next()) {
out.println(rs.getString(1)); }
} catch(Exception e) {
out.print("Error!\n"); out.println(e);
} finally {
if(rs!=null)rs.close(); if(st!=null)st.close(); if(con!=null)con.close();
} %>
1) DataSource ds = (DataSource) initCtx.lookup(“tibero”); 이 부분에서 tibero 부분은
JEUSMain.xml 에서 export-name이랑 일치가 되어야 한다.
5
Tibero-WAS 연동 Guide
© 2011 Tibero Co., Ltd. All Rights Reserved.
3. TOMCAT 4.x 연동
3.1. SERVER.xml 설정
<Context path="" docBase="ROOT" debug="0"> <Resource name="jdbc/tibero" auth="Container" type="javax.sql.DataSource” //jdbc/[export-name] description=”Tibero 4" > </Resource> <ResourceParams name="jdbc/tibero">
<parameter> <name>factory</name> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter> <parameter>
<name>driverClassName</name> <value> com.tmax.tibero.jdbc.TbDriver </value> //classname
</parameter> <parameter>
<name>url</name> <value>jdbc:tibero:thin:@localhost:PORT:SID</value> // 사용 예 : jdbc:tibero:thin:@127.0.0.1:8629:tibero
</parameter> <parameter>
<name>maxActive</name> <value>50</value>
</parameter> <parameter>
<name>maxIdle</name> <value>30</value>
</parameter> <parameter>
<name>maxWait</name> <value>10000</value>
</parameter> <parameter>
<name>username</name> <value>USER</value> //사용 계정
</parameter> <parameter>
<name>password</name> <value>PASSWORD</value> // 계정 Password
</parameter> </ResourceParams>
1) 설정을 하기 젂에 $TB_HOME/client/lib/jar 안에 들어있는 tibero-jdbc.jar 파일을
$CATALINA_HOME/common/lib 안에 복사를 해 넣어야 한다.
2) 이 설정은 TOMCAT 4 이상 버젂에서 사용 하는 설정이다.
3) $CATALINA_HOME/conf/server.xml파일에서 </host>가 끝나는 부분 뒤에 위 내용을
추가하면 된다.
6
Tibero-WAS 연동 Guide
© 2011 Tibero Co., Ltd. All Rights Reserved.
3.2. WEB.xml 설정
<resource-ref> <description> Tibero DataSource</description> <res-ref-name>jdbc/tibero</res-ref-name> // server.xml 에 resource name 와 동일하게 만들어 주시기 바랍니다. <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth>
</resource-ref>
1) $CATALINA_HOME은 TOMCAT 홈 디렉토리 위치이다.
2) $CATALINA_HOME/conf/web.xml 파일의 </web-app > 앞에 위에 내용을 추가한다.
* 나머지 설정 부분에 대해서는 TOMCAT 매뉴얼을 참조하시기 바란다.
3.3. SAMPLE SOURCE (connect.jsp)
<%@ page import="java.sql.*" %> <%@ page import="javax.sql.*" %> <%@ page import="javax.naming.*" %> <%
Connection con=null; Statement st=null; ResultSet rs=null; try {
InitialContext initCtx = new InitialContext(); DataSource ds = (DataSource) initCtx.lookup("java:comp/env/jdbc/tibero"); con=ds.getConnection(); st=con.createStatement(); rs=st.executeQuery("select 'Success!!' from dual"); while(rs.next()) {
out.println(rs.getString(1)); }
} catch(Exception e) {
out.print("Error!\n"); out.println(e);
} finally {
if(rs!=null)rs.close(); if(st!=null)st.close(); if(con!=null)con.close();
} %>
7
Tibero-WAS 연동 Guide
© 2011 Tibero Co., Ltd. All Rights Reserved.
4. TOMCAT 5.5.x 연동
4.1. context.xml 설정
<?xml version="1.0" encoding="UTF-8"?> <Context docBase="ROOT"
path="/ROOT" displayName="Root Context" reloadable="true" cookies="true" swallowOutput="true" override="true" debug="0">
<Resource name="jdbc/tibero” //jdbc/[export-name] auth="Container" type="javax.sql.DataSource" driverClassName="com.tmax.tibero.jdbc.TbDriver” //classname factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" url="jdbc:tibero:thin:@localhost:PORT:SID” // 사용 예 : jdbc:tibero:thin:@127.0.0.1:8629:tibero username="tibero” // 사용 계정 password="tmax” // 계정 Password maxActive="20" maxIdle="10" maxWait="-1" removeAbandoned="true"/>
</Context>
1) 설정을 하시기 젂에 $TB_HOME/client/lib/jar 안에 들어있는 tibero-jdbc.jar 파일을
$CATALINA_HOME/common/lib 안에다가 복사를 해 넣어야 한다.
2) 이 설정은 TOMCAT 5.x 이상 버젂에서 사용 하는 설정이다.
3) $CATALINA_HOME/webapps/[webappname]/META-INF/context.xml 파일을 만드싞 후
위에 설정을 추가 하시면 된다.
4) $CATALINA_HOME 은 TOMCAT 홈 디렉토리 위치이다.
5) 설정 추가가 된 후 변경된 내용을 적용하기 위하여 재부팅을 한다.
* 나머지 설정 부분에 대해서는 TOMCAT 매뉴얼을 참조하시기 바랍니다.
8
Tibero-WAS 연동 Guide
© 2011 Tibero Co., Ltd. All Rights Reserved.
4.2. SAMPLE SOURCE(connect.jsp)
<%@ page import="java.sql.*" %> <%@ page import="javax.sql.*" %> <%@ page import="javax.naming.*" %> <% Connection con=null; Statement st=null; ResultSet rs=null;
try {
InitialContext initCtx = new InitialContext(); DataSource ds = (DataSource) initCtx.lookup("java:comp/env/jdbc/tibero"); con=ds.getConnection(); st=con.createStatement(); rs=st.executeQuery("select 'Success!!' from dual"); while(rs.next()) {
out.println(rs.getString(1)); }
} catch(Exception e) {
out.print("Error!\n"); out.println(e);
} finally {
if(rs!=null)rs.close(); if(st!=null)st.close(); if(con!=null)con.close();
} %>
9
Tibero-WAS 연동 Guide
© 2011 Tibero Co., Ltd. All Rights Reserved.
5. WEBLOGIC 연동
5.1. 콘솔 실행 후 JDBC 설정
[1] JDBC-Connection Pool-Other 생성 Name DBPOOL 이름 설정 Driver Classname com.tmax.tibero.jdbc.TbDriver URL jdbc:tibero:thin:@localhost:PORT:SID // 사용 예 : jdbc:tibero:thin:@127.0.0.1:8629:tibero Database User Name Password [2] JDBC-DataSource 생성 Name , JNDI Name, 바인딩 Connection Pool 설정 [3] Config.xml 자동 적용
5.2. config.xml 설정
<JDBCConnectionPool DriverName="com.tmax.tibero.jdbc.TbDriver" Name="Tibero_ConnPool" Password="{3DES}q3EJJAAGEco=" Properties="user=sys" Targets="myserver" URL="jdbc:tibero:thin:@127.0.0.1:8629:tibero"/> <JDBCTxDataSource JNDIName=“tibero" Name=“tibero" PoolName="Tibero_ConnPool" Targets="myserver"/>
1) tibero-jdbc 드라이버 WL_HOME/server/lib/tibero-jdbc.jar 복사한다.
2) startWebLogic.sh 수정 후 재시작한다.
CLASSPATH=~~:$WL_HOME/server/lib/tibero-jdbc.jar;~~
export CLASSPATH
3.) DataSource ds = (DataSource) initCtx.lookup(“tibero”); 이 부분에서 tibero 부분은
Config.xml에서 JNDIName과 일치가 되어야 한다.
* Weblogic 5.x 경우 weblogic.properties 파일의 url, driver 부분을 수정해준다.
url = com.tmax.tibero.jdbc.TbDriver ,
driver = jdbc:tibero:thin:@localhost:8629:tibero
10
Tibero-WAS 연동 Guide
© 2011 Tibero Co., Ltd. All Rights Reserved.
6. JBOSS 5 연동
6.1. JBOSS 설정
6.1.1. 설치 젂 환경 설정
- JBOSS 5가 jdk6 버젂에서 구동되므로 환경설정의 JAVA_HOME을 jdk6로 변경해 주
어야 한다.
- 환경변수 설정(JAVA_HOME과 PATH 변경)
- JBOSS 홈 디렉토리 설정 후 설치
11
Tibero-WAS 연동 Guide
© 2011 Tibero Co., Ltd. All Rights Reserved.
6.1.2. JDBC 파일 위치
- JBOSS_HOME\server\default\lib의 위치에 odbc14.jar 파일을 넣어 준다.
6.1.3. Tibero와의 연동 테스트
- JBOSS_HOME\server\default\lib의 위치에 odbc14.jar 파일을 넣어 준다.
- JBOSS_HOME\docs\example\jca에 있는 oracle-ds.xml 을 복사하여
JBOSS_HOME\server\default\deploy 위치에 복사한다.
- JBOSS_HOME\server\default\deploy의 Oracle-ds.xml을 Tibero-ds.xml로 아래와
같이 수정한다.(기존의 Orace-ds.xml은 삭제 하거나 Oracle-ds.xml.bak으로 수정)
<datasources> <local-tx-datasource>
<jndi-name>TiberoDS</jndi-name> //JNDI를 이용 하여 불러올 때 이름을 설정하는 부분입니다.
<connection-url>jdbc:tibero:thin:@127.0.0.1:8629:tibero</connection-url> <driver-class>com.tmax.tibero.jdbc.TbDriver </driver-class> <user-name>tibero </user-name> // 접속 user 계정 <password>tmax</password> // 접속 user passwd <exception-sorter-class-name>
org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter </exception-sorter-class-name> <metadata> <type-mapping>Oracle9i</type-mapping> </metadata>
</local-tx-datasource> </datasources>
12
Tibero-WAS 연동 Guide
© 2011 Tibero Co., Ltd. All Rights Reserved.
- File->New->Dynamic Webproject 클릭-> project_name(JBOSS_Tibero) 주고 finish.
test_tibero.jsp 파일 생성
생성된 프로젝트에서 마우스 오른쪽 버튼 클릭 후 new -> JSP 선택 -> test.jsp
<%@ page import="java.sql.*" %> <%@ page import="javax.sql.*" %> <%@ page import="javax.naming.*" %> <% Connection con=null; Statement st=null; ResultSet rs=null; try { InitialContext initCtx = new InitialContext(); DataSource ds = (DataSource) initCtx.lookup("java:/TiberoDS"); con=ds.getConnection(); st=con.createStatement(); rs=st.executeQuery("select table_name from user_tables"); while(rs.next()) { out.println(rs.getString(1)); } } catch(Exception e) { out.print("Error!\n"); out.println(e); } finally { if(rs!=null)rs.close(); if(st!=null)st.close(); if(con!=null)con.close(); } %>
13
Tibero-WAS 연동 Guide
© 2011 Tibero Co., Ltd. All Rights Reserved.
6.1.4. 서버에 해당 프로젝트 추가 하기
14
Tibero-WAS 연동 Guide
© 2011 Tibero Co., Ltd. All Rights Reserved.
Server 에 해당 프로젝트 추가 완료
6.1.5. JSP Test (Tibero)
15
Tibero-WAS 연동 Guide
© 2011 Tibero Co., Ltd. All Rights Reserved.
Information Intelligence, Tibero
Click to sub Title