태터데스크 관리자

도움말
닫기
적용하기   첫페이지 만들기

태터데스크 메시지

저장하였습니다.

Container를 이용해서 pool객체를 이용하기 위해서는 JNDI를 이용해야 한다.
JNDI는 J2EE의 javax.naming.* 패키지안의 JNDI 클래스를 import해야한다.

==============   데이터를 처리하는 JDBC 로직을 수행하는 파일  ==============

<%@ page import="javax.sql.*"%>
<%@ page import="javax.naming.*"%>

<%
.
.
.
 Context initCtx = new InitialContext();
 Context envCtx = (Context)initCtx.lookup("java:comp/env");
 DataSource ds = (DataSource)envCtx.lookup("jdbc/MySQLDataSource");
 con = ds.getConnection();
.
.
.
%>


그리고 프로젝트 WEB-INF\web.xml과 %CATALINA_HOME%\conf\server.xml 을 수정해야 한다.
================ web.xml ============================
<resource-ref>element를 추가한다.
=====================================================

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">

.
.
.

  <resource-ref>
   <res-ref-name>jdbc/MySQLDataSource</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
  </resource-ref>
.
.
.
</web-app>

================ server.xml ============================
<Resource>element를 두 곳에 추가한다.
=======================================================

<Server port="8005" shutdown="SHUTDOWN">
.
.
.
  <GlobalNamingResources>
       <Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>


      <Resource auth="Container" name="jdbc/MySQLDataSource" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" password="1234" maxIdle="2" maxWait="5000" username="jspuser"
   url="jdbc:mysql://localhost:3306/testboarddb"
   maxActive="4"/>

  </GlobalNamingResources>
.
.
.
  <Service name="Catalina">
.
.
.
    <Engine defaultHost="localhost" name="Catalina">
.
.
.
        <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
.
.
.
           <Context docBase="TestBoard" path="/TestBoard" reloadable="true" source="org.eclipse.jst.jee.server:TtestBoard">

              <Resource auth="Container" name="jdbc/MySQLDataSource" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" password="1234" maxIdle="2" maxWait="5000" username="jspuser"
   url="jdbc:mysql://localhost:3306/testboarddb"
   maxActive="4"/>

           </Context>

       </Host>
    </Engine>
  </Service>
</Server>
top

Trackback Address :: http://www.ssial.com/trackback/139 관련글 쓰기

  1. Chanel Outlet 2011/09/17 21:30 댓글주소 | 수정/삭제 | 댓글

    Time is what you make of it.

  2. Burberry Bags 2011/10/13 17:11 댓글주소 | 수정/삭제 | 댓글

    I'm happy I found this blog! From time to time students want to cognitive the keys of productive literary essays composing. Your first-class knowledge about this good post can become a proper basis for such people. Thanks.

  3. Coach Outlet Online 2011/11/15 12:24 댓글주소 | 수정/삭제 | 댓글

    It's very good!Thank you for sharing it!I like buying handbags of the internet website:http://www.mycoachoutletstoreonline.com

  4. Coach Factory Online 2011/12/11 23:00 댓글주소 | 수정/삭제 | 댓글

    댓글주소 | 수정/삭제 | 댓글

  5. Coach Factory Outlet Online 2011/12/14 15:58 댓글주소 | 수정/삭제 | 댓글

    Great Coach Factory Outlet Online
    . A lot of useful information here. I’m sending it to some friends!

  6. abercrombie and fitch deutschland 2012/02/07 16:56 댓글주소 | 수정/삭제 | 댓글

    Keep up the good work!.

  7. abercrombie 2012/02/07 16:56 댓글주소 | 수정/삭제 | 댓글

    This was very informative. I have been reading your blog a lot over the past few days and it has earned a place in my bookmarks.

Write a comment


◀ PREV : [1] : ... [95] : [96] : [97] : [98] : [99] : [100] : [101] : [102] : [103] : ... [206] : NEXT ▶