나의 마음을 ctrl+c,너의 가슴에 ctrl+v

아래 Sql을 실행
/* 복원할 database가 기존에 있고, 삭제를 해야하는 경우 */
ALTER DATABASE testDatabase SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
Drop DATABASE testDatabase;

/* 복원할 파일 확인 */
Restore FileListOnly From Disk = 'c:\testDatabase.bak';  /* 검색된 LogicalName 을 아래에서 사용 */

/* 복원, 용량에 따라 시간이 다소 걸림 */
Restore Database nyl_new From Disk = 'c:\testDatabase.bak';
With Move 'testDatabase_Data' to 'F:\mssql save repository\testDatabase.mdf'
,Move 'testDatabase_Log' to 'F:\mssql save repository\testDatabase.ldf';

lib 추가
commons-collections-2.1.1.jar
commons-dbcp-1.2.2.jar
commons-pool-1.3.jar

Server >> Apache Tomcat v.6.0-config
server.xml

<?xml version="1.0" encoding="UTF-8"?>
  <Server port="8005" shutdown="SHUTDOWN">
  <Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
  <Listener className="org.apache.catalina.core.JasperListener"/>
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>

  <!-- Global JNDI resources Documentation at /docs/jndi-resources-howto.html -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by UserDatabaseRealm to authenticate users -->
    <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"/>

 <!-- ##### JNDI Modify point 1 #################### -->
    <Resource auth="Container" driverClassName="oracle.jdbc.OracleDriver" maxActive="20" maxIdle="10" maxWait="-1" name="comp/env" password="take1" type="javax.sql.DataSource" url="jdbc:oracle:thin:@10.10.10.10:1521:ORCL" username="take2"/>
 <!-- #################### JNDI Modify point 1 ##### -->

  </GlobalNamingResources>

  <Service name="Catalina">
    <Connector connectionTimeout="20000" port="8088" protocol="HTTP/1.1" redirectPort="8443" URLEncoding="euc-kr"/>
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
    <Engine defaultHost="localhost" name="Catalina">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
      <Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
    <Context docBase="inno" path="/" reloadable="true" source="org.eclipse.jst.j2ee.server:inno"/></Context>
      </Host>
    </Engine>
  </Service>
</Server>


context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context>
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <!--
         Was DataSource 명은 name attribute 값과 일치하고,
         server.xml 의 GlobalNamingResources Resource name 은 ResourceLink global 과 일치해야함
    -->  
    <ResourceLink name="comp/env" global="comp/env" type="javax.sql.DataSource" /> 
</Context> 


test.jsp

<%@ page contentType="text/html;charset=utf-8" %>
<%@ page import="java.sql.*" %><%
/**
 * JNDI 연결확인 테스트 파일입니다.
 * @author : gggl.ko
 */
String jndi = (request.getParameter("jndi") == null ? "java:comp/env/comp/env" : request.getParameter("jndi"));
Connection conn = null;

try {

    javax.naming.Context context = new javax.naming.InitialContext();
    System.out.println("[접속테스트] JNDI 명 = " + jndi);
    javax.sql.DataSource ds = (javax.sql.DataSource) context.lookup(jndi);
    conn = ds.getConnection();

} catch(Exception e) {
    System.out.println(e);
    out.println(e.getLocalizedMessage());
    return;
}

* Tomcat 의 경우는 접두어로 java:comp/env/ 를 붙여줘야 한다. 예) java:comp/env/comp/env

 

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

// substring
// java : "123abc".substring(2, 5); // return 3ab
${fn:substring("20120102", 4, 6)} <!-- return 01 -->

// split
${fn:split("abc@def.com","@")[0]} <!-- return "abc" -->
${fn:split("abc@def.com","@")[1]} <!-- return "def.com" -->

// join(array, separator)
-> eaual javascript join

// indexOf
${fn:indexOf("abc@def.com","@")} <!-- return 3 -->

// length
${fn:length('abc')} <!-- return 3 -->
${fn:length('')} <!-- return 0 -->
${fn:length(null)} <!-- return 0 -->

// replace
<%
pageContext.setAttribute("cr", "\r");       
pageContext.setAttribute("cn", "\n");      
pageContext.setAttribute("crcn", "\r\n");
pageContext.setAttribute("br", "<br/>");
%>
${fn:replace(result.contents,cn, br)}

// collection 및 List 객체의 size return
<c:set var="takeSize" value="${fn:length(takeList)}" />

// contains
${fn:contains('abc','b')}<!-- return true -->

// containsIgnoreCase
${fn:contains('aBc','b')}<!-- return true -->

// startsWith
${fn:startsWith('aBc','aB')}<!-- return true -->

// endsWith
${fn:endsWith('aBc','Bc')}<!-- return true -->

// trim(String) -> equal java trim

// escapeXml("<a>b</a>")

// substringAfter
${fn:substringAfter('aBcDef','Bc')}<!-- return 'Def' -->

// substringBefore
${fn:substringBefore('aBcDef','Bc')}<!-- return 'a' -->

// fn:toLowerCase(string)
-> equal java toLowerCase

// fn:toUpperCase(string)
-> equal java toLowerCase

 

'java > coding' 카테고리의 다른 글

jQuery plugin 정리 (+ bootstrap color picker 포함)  (0) 2014.05.15
[도움말] jQuery 1.4 chm  (0) 2013.10.24
web.xml filter  (1) 2012.07.11