달력

5

« 2024/5 »

  • 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
2008. 10. 21. 10:31

JavaOne site 그거/Java2008. 10. 21. 10:31

'그거 > Java' 카테고리의 다른 글

Ergonomics in the 5.0 Java[tm] Virtual Machine  (0) 2008.10.31
Java CAPS 관련 사이트  (0) 2008.10.21
Java Heapsize 관련 참조  (0) 2008.10.21
eclipse TPTP update  (0) 2008.10.08
참, 자바란 것이 어렵다 ㅜㅜ  (1) 2007.10.24
:
Posted by 뽀기
2008. 10. 21. 09:40

Java Heapsize 관련 참조 그거/Java2008. 10. 21. 09:40

'그거 > Java' 카테고리의 다른 글

Java CAPS 관련 사이트  (0) 2008.10.21
JavaOne site  (0) 2008.10.21
eclipse TPTP update  (0) 2008.10.08
참, 자바란 것이 어렵다 ㅜㅜ  (1) 2007.10.24
WebLogic 8.1 SP6 Download URL  (0) 2007.09.17
:
Posted by 뽀기
2008. 10. 8. 10:14

eclipse TPTP update 그거/Java2008. 10. 8. 10:14

eclipse Test & Performance Tools Platform Project

 

eclipse 에서 update 하려면

Help > Software updates > find and install > new remote site 해서

name : TPTP update Site
url :
http://eclipse.org/tptp/updates/site.xml


추가하고 update 하면 끝!

'그거 > Java' 카테고리의 다른 글

JavaOne site  (0) 2008.10.21
Java Heapsize 관련 참조  (0) 2008.10.21
참, 자바란 것이 어렵다 ㅜㅜ  (1) 2007.10.24
WebLogic 8.1 SP6 Download URL  (0) 2007.09.17
[JavaQuiz] 3n+1  (0) 2007.09.12
:
Posted by 뽀기

#!/bin/sh

set -A port 8887 8888 9998 9999
established=0
close_wait=0
listen=0
i=0

while [ $i -lt ${#port[@]} ]
do
echo "CHECK Port number : ${port[$i]}"
  for state in `netstat -an | grep ${port[$i]} | awk '{print $6}'`
  do
    if [ $state = 'ESTABLISHED' ]; then
      let "established+=1"
    fi

    if [ $state = 'CLOSE_WAIT' ]; then
      let "close_wait+=1"
    fi

    if [ $state = 'LISTEN' ]; then
      let "listen+=1"
    fi

  done

  echo "       ESTABLISHED (${port[$i]}): $established"
  echo "       CLOSE_WAIT  (${port[$i]}): $close_wait"
  echo "       LISTEN      (${port[$i]}): $listen"
  let "i+=1"

done

:
Posted by 뽀기

#!/bin/sh
today=`date +'%Y-%m-%d`

echo ""
echo " Today is $today"
echo ""

# 로그파일에서 날짜를 추출하여, 각 날짜마다의 로그파일에 대해서 아래 내용을 수행한다.
# 01. tar cvf server.log_{yyyy-mm-dd}.tar server.log_{yyyy-mm-dd}T*
# 02. rm -f server.log_{yyyy-mm-dd}T*
# 03. compress server.log_{yyyy-mm-dd}.tar

for logfiledate in `ls -al server.log_*T* | awk '{print $9}' | cut -c 1-21 | uniq -c | awk '{print $2}'`
do
  # 오늘 날짜의 log는 백업하지 않는다. 어제 날짜까지의 로그파일을 백업하도록 한다.
  tdate=`echo $logfiledate | cut -c 12-22`
  if [ $today = $tdate ]; then
    exit;
  fi
  tarfile=$logfiledate".tar"
  logfile=$logfiledate"T*"

  echo "-----------------------------"
  echo "         $tdate"
  echo "-----------------------------"
  echo "01. Make tar file           : tar cvf $tarfile $logfile"
  tar cvf $tarfile $logfile 2> /dev/null

  echo "02. Delete log archive file : rm -f $logfile"
  rm -f $logfile

  echo "03. Compress tar file       : compress $tarfile"
  compress $tarfile

  echo ""
done

:
Posted by 뽀기
2008. 9. 9. 13:44

Solaris 에서 ISO 이미지 mount 하는 법 그거/Tech2008. 9. 9. 13:44



lofiadm -a /export/temp/software.iso /dev/lofi/1

mount -F hsfs -o ro /dev/lofi/1 /mnt
:
Posted by 뽀기
2008. 7. 2. 08:37

HP 이벤트 진행중~~ 그거/기타2008. 7. 2. 08:37



커피라도 먹어보세요~

'그거 > 기타' 카테고리의 다른 글

IT 산업 노조라는게 있답니다.  (0) 2009.04.30
SW 기술자 신고제도라는게 있다는데.  (0) 2009.04.30
IDE & ATA & SCSI  (0) 2007.11.05
AJAX 사이트  (0) 2007.10.26
15 Exercises for Learning a new Programming Language  (0) 2007.07.24
:
Posted by 뽀기
2008. 1. 31. 15:23

Velocity 따라하기 - 1번 예제 - 그거/Tech2008. 1. 31. 15:23


1. velocity-1.5.zip 파일을 다운로드 받아서 압축을 해제한다.
2. velocity-1.5.jar, commons-collections-3.1.jar, commons-lang-2.1.jar 파일을 classpath에 등록한다.
3. example.vm 파일을 생성하여 template을 작성한다.

   #set( ${this} = "Velocity")

   ${this} is great!
  
   #foreach( ${name} in ${list} )
       ${name} is great!
   #end
  
   #set( ${condition} = true)
  
   #if (${condition})
       The condition is true!
   #else
       The condition is false!
   #end


4. Example.java 파일을 생성하여 위에서 작성한 template 파일을 읽어서 처리한다.

   // Velocity 의 환경 설정
   // velocity.properties 파일에는 runtime.log = velocity_example.log 이런 내용이 들어간다.
   Velocity.init("velocity.properties");
  
   // VelocityContext를 만들어서 template 파일에서 사용할 변수를 설정한다.
   VelocityContext context = new VelocityContext();
   // 아래의 "list" 는 template 파일에서 ${list} 로 사용된다.
   context.put("list", XXX);
  
   // template 파일을 지정하여 Template class를 생성한다.
   Template template = Velocity.getTemplate(templageFile);
  
   // rendering 된 template이 출력될 output을 지정한다.
   BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(System.out) );
   template.merge(context, writer);
  
   // rendering 된 template을 출력한다.
   writer.flush();
   writer.close();


5. Example.java 컴파일 하고 실행한다.

$ javac -classpath .;..\..\velocity-1.5.jar Example.java
$ java -classpath .;..\..\velocity-1.5.jar; \
                          ..\..\lib\commons-collections-3.1.jar; \
                          ..\..\lib\commons-lang-2.1.jar \
                          Example example.vm

2008. 1. 31 오후 2:24:49 org.apache.velocity.runtime.log.JdkLogChute log
정보: FileResourceLoader : adding path '.'


Velocity is great!

    ArrayList element 1 is great!
    ArrayList element 2 is great!
    ArrayList element 3 is great!
    ArrayList element 4 is great!


    The condition is true!







:
Posted by 뽀기
2008. 1. 23. 16:56

iBatis 따라하기 2 (중고차 정보) 그거/Tech2008. 1. 23. 16:56


# package

  ibatis.dto                     : DTO 가 있는 package
  ibatis.dao                     : DAO 프로그램이 있는 package
  ibatis.dao.sqlmapdao           : xml 파일 위치
  ibatis.biz                     : DAO, DTO를 사용해서 테스트할 프로그램이 있는 package
  ibatis.properties              : property 파일이 있는 위치

# file

  ibatis.dto.Car.java                             : DTO(자동차에 대한 간단한 정보 저장)
  ibatis.dao.SqlMapFactory.java                   : sql-map-config.xml 파일을 resource로 하는 SqlMapClient 반환
  ibatis.dao.sqlmap.CarDAO.java                   : SqlMapClient의 method들을 wrapping
  ibatis.dao.sqlmap.sql.car.xml                   : sql문이 있는 XML 파일
  ibatis.dao.sqlmap.sql.sql-map-config.xml        : sqlMap 정보(sql문이 있는 XML 파일)와 Transaction 관련 정보 XML 파일
  ibatis.biz.CarTest.java                         : iBatis를 이용해 테스트할 프로그램
  ibatis.properties.sql-map-config.properties     : DB 연결 정보가 있는 파일

# 따라하기 순서

1. 자동차 정보를 저장할 간단한 DTO인 Car.java를 만든다.

   id, company, name, year, price
   물론, getter, setter도 생성해야 한다!

2. iBatis를 이용하여 자동차 정보를 DB에서 조작하는 DAO를 만든다.

   public List<Car> getCarList(int skip, int num) throws SQLException { ... 중략 ... }
   public void insertCar(Car car) throws SQLException { ... 중략 ... }
   public void updateCar(Car car) throws SQLException { ... 중략 ... }
   public void deleteCar(Car car) throws SQLException { ... 중략 ... }
   public Car getCar(String id) throws SQLException { ... 중략 ... }
   SqlMapClient 로 부터 직접 method들을 호출할 수도 있지만, 그냥 Wrapper class를 만들었다.

3. 2번에서 생성한 DAO를 이용하여 DB 조작을 테스트하는 테스트 프로그램을 작성한다.

   insert/update/delete/select 등을 각각 수행해볼 수 있는 프로그램을 작성한다.

   Car car = new Car();
   CarDAO cardao = new CarDAO();

   // insert
   car.setCompany("Hyundai");
   car.setName("Lavita");
   car.setPrice("6,000,000");
   car.setYear("2002");
   cardao.insertCar(car);

   // select
   car = cardao.getCar("1");

   // update
   car.setPrice("8,000,000");
   cardao.update(car);

   // delete
   cardao.delete(car);

4. 테스트 프로그램에서 select/insert/update/delete 등이 호출될 때 iBatis에서 사용하는 sql query 문을 작성한다.

 <select id="getCar" resultClass="car">
  SELECT ID, NAME ... 중략 ...
  
 <insert id="insertCar" parameterClass="car">
  INSERT INTO CAR ... 중략 ...

 <update id="updateCar" parameterClass="car">
  UPDATE CAR SET  ... 중략 ...

 <delete id="deleteCar" parameterClass="car">
  DELETE FROM CAR ... 중략 ...

 <select id="getCarList" resultClass="car">
  SELECT ID, NAME, ... 중략 ...

5. iBatis에서 위에서 정의한 sql query를 사용할 수 있도록 sqlMap 정보를 설정하고, DB 연결 정보를 설정하는 xml 파일을 만든다.

   <sqlMapConfig>
     <properties resource="ibatis/properties/sql-map-config.properties"/>

     ... 중략 ...

     <transactionManager type="JDBC" commitRequired="false">
        <dataSource type="SIMPLE">
    <property name="JDBC.Driver" value="${driver}"/>
    <property name="JDBC.ConnectionURL" value="${url}"/>
    <property name="JDBC.Username" value="${username}"/>
    <property name="JDBC.Password" value="${password}"/>

     ... 중략 ...

     <sqlMap resource="ibatis/dao/sqlmapdao/sql/car.xml"/>

     ... 중략 ...

   </sqlMapConfig>

6. DB 연결 정보를 설정할 properties 파일을 만든다.

   driver=com.mysql.jdbc.Driver
   url=jdbc:mysql://localhost:3306/jsptest
   username=lucky
   password=lucky

7. SqlMapClient 객체를 singleton pattern 을 이용하여 하나의 instance만 생성하여 사용할 수 있도록 한다.

   private static SqlMapClient sqlMap;
  
   static {
      try {
         String resource = "ibatis/dao/sqlmapdao/sql/sql-map-config.xml";
         Reader reader = Resources.getResourceAsReader(resource);
         sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
      } catch(Exception e) {
         e.printStackTrace();
         throw new RuntimeException("Error while initializing SqlMapClient : "  + e);
      }
   }
  
   public static SqlMapClient getInstance() {
      return sqlMap;
   }

8. 3번에서 작성한 테스트 프로그램을 eclipse에서 실행해본다.

   [1] Company = Hyundai, Name = Avante, year = 2001, price = 8,000,000
   [2] Company = Hyundai, Name = Lavita, year = 2002, price = 6,000,000
   [3] Company = Hyundai, Name = Sonata, year = 2006, price = 16,000,000

* 참고사항

  이전에 실행해봤던 예제를 보면, xml/properties 파일들이 default package의 class 파일과 같은 위치에 있었어야 했으나
  이번 예제처럼 package 를 설정하여 class 파일과 구분하여 놓으면
  프로그램 실행할 때 ClassLoader를 기준으로 찾기 때문에

  resource="ibatis/properties/sql-map-config.properties"
  resource="ibatis/dao/sqlmapdao/sql/car.xml"

  위와 같이 가장 상위 package 부터 경로를 작성하면 된다.















'그거 > Tech' 카테고리의 다른 글

Solaris 에서 ISO 이미지 mount 하는 법  (0) 2008.09.09
Velocity 따라하기 - 1번 예제 -  (0) 2008.01.31
iBatis 예제 따라하기~!  (0) 2008.01.22
[JDK 1.4 VS JDK 1.5] Boolean.TRUE 와 true  (0) 2007.11.05
[Network] OSI 7 Layer  (0) 2007.10.31
:
Posted by 뽀기
2008. 1. 22. 17:23

iBatis 예제 따라하기~! 그거/Tech2008. 1. 22. 17:23

iBatis를 해보고자 예제 실습을 따라했다.

# 필요한 파일

1. Member.xml
2. SqlMapConfigExample.properties
3. SqlMapConfigExample.xml
4. Member.java
5. MemberApp.java

# 필요한 것들

1. MySql, Oracle, MSSQL 등등의 DB
2. 1번 DB에 접속할 수 있는 접속 정보(URL, ID, PASSWD, DB Name 등등)



# 실습 순서

1. DB에 접속하여 Member table의 schema를 확인한다
   SQL> desc MEMBER
   (#id#, #passwd#, #name#, #jumin1#, #jumin2#, #email#, #url#, #addr#, #tel_no#, #regdate#)
2. 1번에서 확인한 사항을 바탕으로 DTO(Member.java)를 생성한다.
    private String id;
    ... 중략...
    private String regdate;

    public String getId() {
        return id;
    }
    ...중략...
    public void setId(String id) {
        this.id = id;
    }
    ....중략...
3. SqlMapConfigExample.xml 파일을 만든다.
  <properties resource="SqlMapConfigExample.properties"/>
  <transactionManager type="JDBC" commitRequired="false">
    <dataSource type="SIMPLE">
       <property name="JDBC.Driver" value="${driver}"/>
       <property name="JDBC.ConnectionURL" value="${url}"/>
       <property name="JDBC.Username" value="${username}"/>
       <property name="JDBC.Password" value="${password}"/>
    </dataSource>
  </transactionManager>
  <sqlMap resource="Member.xml"/>
4. SqlMapConfigExample.properties 파일을 생성한다.
   driver=com.mysql.jdbc.Driver
   url=jdbc:mysql://localhost:3306/jsptest
   username=lucky
   password=lucky
5. Member.xml 파일을 생성하여 select, insert, update, delete 를 실행하기 위한 query를 정의한다.
 <select id="getMember" resultClass="Member">
  SELECT ID, PASSWD, NAME, JUMIN1,  ...중략... WHERE ID = #value#
 </select>
 <insert id="insertMember" parameterClass="Member">
  INSERT INTO MEMBER(ID, ...중략...) VALUES(#id#, ...중략...)
 </insert>
 <update id="updateMember" parameterClass="Member">
  UPDATE MEMBER ...중략...
 </update>
 <delete id="deleteMember" parameterClass="Member">
  DELETE ...중략...
 </delete>
6. compile
    $ javac -classpath .;..\..\..\lib\ibatis-2.3.0.677.jar *.java
7. run
    $ java -classpath .;..\..\..\lib\ibatis-2.3.0.677.jar;..\..\..\lib\mysql-connector-java-5.0.4-bin.jar MemberApp


# 주의사항
MemberApp.java 소스 중에

String resource = "SqlMapConfigExample.xml";
Reader reader = Resources.getResourceAsReader(resource);

이런 내용이 있는데, Resources.getResourceAsReader() 이 method가
resource를 classloader 기준으로 찾기 때문에
위의 xml 파일들이 class 파일이 위치한 곳에 같이 있어야 한다.

처음에 eclipse 에서 해보려고, package 만들어서 class 만들고 xml 파일은 다른 폴더에 저장하고 별~~ 삽질을 다 해봤으나 계속 "Could not found resource" 라는 exception만 뱉어냈었다.
eclipse에서의 문제 해결은 못하고, 우선 실행을 해봐야겠기에 전부 한 폴더에 몰아놓고 테스트 했다.











'그거 > Tech' 카테고리의 다른 글

Velocity 따라하기 - 1번 예제 -  (0) 2008.01.31
iBatis 따라하기 2 (중고차 정보)  (0) 2008.01.23
[JDK 1.4 VS JDK 1.5] Boolean.TRUE 와 true  (0) 2007.11.05
[Network] OSI 7 Layer  (0) 2007.10.31
Tomcat에서 JDBC driver 설정~!  (0) 2007.10.22
:
Posted by 뽀기