'2008/Spring 2.5'에 해당되는 글 6건

  1. 2008.10.30 JEUS 4.2설정
  2. 2008.09.20 5교시 DBConnection
  3. 2008.09.20 4교시 SpringFramework 설정
  4. 2008.09.20 3교시_2 톰켓 설정
  5. 2008.09.20 첫번째 3번째 시간
  6. 2008.09.20 spring 1차 수업
2008/Spring 2.52008. 10. 30. 11:04
Posted by penguindori
2008/Spring 2.52008. 9. 20. 17:12
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <!-- the test application context definition for the jdbc based tests -->

    <bean id="productDao" class="springapp.repository.JdbcProductDao">
        <property name="dataSource" ref="dataSource" />
    </bean>

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName" value="${jdbc.driverClassName}"/>
      <property name="url" value="${jdbc.url}"/>
      <property name="username"  value="${jdbc.username}"/>
      <property name="password" value="${jdbc.password}"/>
    </bean>
    <bean id="propertyConfigurer"
          class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:jdbc.properties</value>
            </list>
        </property>
    </bean>
   
    <bean id="transactionManager"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>

</beans>

=================================
Document path
C:\spring\util\apache-tomcat-5.5.27\webapps\tomcat-docs\index.html

8) JNDI Resources



4. Configure Tomcat's Resource Factory

To configure Tomcat's resource factory, add an elements like this to the $CATALINA_HOME/conf/server.xml file, nested inside the Context element for this web application.

<Context ...>
  ...
  <Resource name="bean/MyBeanFactory" auth="Container"
            type="com.mycompany.MyBean"
            factory="com.mycompany.MyBeanFactory"
            bar="23"/>
  ...
</Context>

Note that the resource name (here, bean/MyBeanFactory must match the value specified in the web application deployment descriptor. We are also initializing the value of the bar property, which will cause setBar(23) to be called before the new bean is returned. Because we are not initializing the foo property (although we could have), the bean will contain whatever default value is set up by its constructor.


tomcat Server.xml 설정
<GlobalNamingResources>
 <Resource name="jdbc/SpringDB" auth="Container"
            type="javax.sql.DataSource" username="spring" password="spring123"
            driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@localhost:1521:XE"
            maxActive="8" maxIdle="4"/>

</GlobalNamingResources> 



맨밑에
 <Context docBase="spring_1"
      path="/spring_1"
      reloadable="true"
      source="org.eclipse.jst.j2ee.server:spring_1">
      <ResourceLink name="jdbc/SpringDB"
            global="jdbc/SpringDB"
            type="javax.sql.DataSource"/>
      </Context>



설정 하고 나서 Test_jndi.jsp 만들어서 Test를 해봅시다.

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
   
<%@ page import="java.sql.*" %>
<%@ page import="javax.naming.*" %>
   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<% InitialContext ctx = new InitialContext();
   Object  obj = ctx.lookup("java:comp/env/jdbc/SpringDB");
  
   if(obj  != null)
   {
    javax.sql.DataSource ds = (javax.sql.DataSource)obj;
    
    Connection conn = ds.getConnection();
    Statement stmt = conn.createStatement();
    String sql = "SELECT * FROM BOARD ";
    ResultSet rs = stmt.executeQuery(sql);
    
    while(rs.next())
    {
     out.println(rs.getString(1) + "<br>");
    }
    stmt.close();
    conn.close();
    
   }
   else {
    out.println("검색 실패 !!");
   }
  
   %>

</body>
</html>

Posted by penguindori
2008/Spring 2.52008. 9. 20. 14:05

http://static.springframework.org/docs/Spring-MVC-step-by-step/part1.html

web.xml 추가

<servlet>
    <servlet-name>springapp</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>springapp</servlet-name>
    <url-pattern>*.htm</url-pattern> -> *.do로 수정
  </servlet-mapping>



2.
C:\spring\util\spring-framework-2.5.5\dist
(1.7 step by step)

spring.jar
spring-webmvc.jar  드레그 해서 이클립스 Webcontent/WEB-INF/lib/에 넣는다.

--------------------
springapp-servlet.xml  <-- 이름으로 하나 만든다.

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

  <!-- the application context definition for the springapp DispatcherServlet -->

  <bean name="/hello.htm" class="springapp.web.HelloController"/>

</beans>




<bean name="/hello.htm" class="springapp.web.HelloController"/>  요청 Url

<bean id="">  ID 공유할때는 ID ; 특스문자 사용 불가

<!-- http://localhost:8088/spring_1/hello.do -->
  <bean name="/hello.do" class="springapp.web.HelloController"/>




=======================================
1. springapp-servlet.xml
  <?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

  <!-- the application context definition for the springapp DispatcherServlet -->
 <!-- http://localhost:8088/spring_1/hello.do -->
  <bean name="/hello.do" class="springapp.web.HelloController"/>
 //springapp.web.HelloController를 /hello.do로 매핑 합니다.

</beans>

2. HelloController.java class 만들기

package springapp.web;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

//import org.apache.commons.logging.Log;
//import org.apache.commons.logging.LogFactory;

import java.io.IOException;


public class HelloController implements Controller {
 @Override
 public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
       throws Exception
 {
 
  ModelAndView mv = new ModelAndView();
  mv.setViewName("spring_hello.jsp");
  mv.addObject("greeting","첫번째 스프링 예제!!!");
  return mv;
 }
 
}

3. jsp Page만들기
spring_hello.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
 ${greeting}
</body>
</html>

4. index.htm
<html>
<head>
<script type="text/javascript">
<!--
 location.href="hello.do";
-->
</script>
</head>
<body>
</body>

</html>
----------- 그러면 나온다 ; 아 힘드네 ㅋㅋ


사용자 삽입 이미지













Posted by penguindori
2008/Spring 2.52008. 9. 20. 12:10
톰켓을 설정해 봅시다.

사용자 삽입 이미지

2.
사용자 삽입 이미지
위에 보이는 New를 클릭 합니다.

3.
사용자 삽입 이미지
톰켓 5.5를 할려고 다운받았으니 5.5를 선택 합니다.

4.그러고 그냥 Next -> Next-> Finish를 누릅니다. (톰켓 선택시 그냥 톰켓이 들어있는 폴터를 냅다
  선택

5. 그후 Run 하면 됩니다. 혹시 Oracle Port와 충돌이 발생하여 작동이 안하면

  
사용자 삽입 이미지


server.xml 에서 8080을 다른걸로 바꺼준다 예를들어서 8088 이렇게 ㅎㅎ

사용자 삽입 이미지
Posted by penguindori
2008/Spring 2.52008. 9. 20. 11:58
- Eclipse 설정

Help -> SorfWare Update -> Find and Install

1.
사용자 삽입 이미지

2.
사용자 삽입 이미지

3.
 
사용자 삽입 이미지
Select Required : 선택 한 사항 알아서 필요 시스템 체크 해줌..
J2SE, JAVA 나와있는거 클릭후 위의 버튼 클릭

4.
사용자 삽입 이미지

아무튼 여기서 그냥 넥스트 누루고 알아서 ^^;

다음은 톰켓 설정 ^^*



Posted by penguindori
2008/Spring 2.52008. 9. 20. 09:21

1일차
1.apache
  http://apache.org/
  (http://tomcat.apache.org/)
2. Eclipse 다운로드
  http://eclipse.org
3. 스프링 프레임워크
  http://springframework.org/download
(http://sourceforge.net/project/showfiles.php?group_id=73357&package_id=173644&release_id=608794)
4. Oracle
   http://oracle.com
  C:Spring 폴더 생성
    util안에   1)apache-tomcat-5.5.27
                2)eclipse-SDK-3.3.2-win32
                3)spring-framework-2.5.5-with-docs
                4)OracleXEUniv.exe
                                                            필요 합니다.

설치..

오라클 설치후

>SQL>SQL 명령
select * from tabs (Ctrl + Enter)실행

---------------
오라클 설정
--------------
1. 계정 생성
2. Tabel Create
  board
  


테이블 생성    
 
열 이름 유형 전체 자릿수 소수점 이하 자릿수 널이 아님 이동
아래로 열 이동위로 열 이동
아래로 열 이동위로 열 이동
아래로 열 이동위로 열 이동
아래로 열 이동위로 열 이동
아래로 열 이동위로 열 이동
아래로 열 이동위로 열 이동
아래로 열 이동위로 열 이동
아래로 열 이동위로 열 이동
아래로 열 이동위로 열 이동


 
Posted by penguindori