'2009/06/01'에 해당되는 글 3건

  1. 2009.06.01 pstmt.setTimestamp() 로 date형식 Insert 1
  2. 2009.06.01 jquery 에서 부모객체 참조; 2
  3. 2009.06.01 생성자 패턴 1


SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  //date포맷 생성

query = " INSERT INTO TBLTIME ( TIMETEST ) VALUES ( ? ) ";
pstmt = conn.prepareStatement(query);
pstmt.setTimestamp(1 , new Timestamp( sdf.parse("2009-06-01 19:02:33").getTime() )); //TimeStamp 생성 & set
pstmt.executeUpdate();

ORACLE, MSSQL, MYSQL 확인완료;
DB마다 상이한 내장함수를 사용할 필요가 없음;
(ex. TO_DATE() )


psmt.setDate()는 날짜까지만 입력이 되는데... 
원래그런건지... 그이유는..잘.; 
Posted by 알 수 없는 사용자 :

1. parent일경우

var $ = window.parent.$;

$("#name").val("우왕ㅋ굳ㅋ");

alert($("#name").val());

 

결과는 부모도큐먼트의 name객체의 value를 반환

"우왕ㅋ굳ㅋ"

출력

  

2. opener일 경우

$("#name", opener.document ).val("우왕ㅋ굳ㅋ");

alert($("#name").val());

 

opener, parent 일경우가 서로 다르다...

왜그럴까??;;

 

Posted by 알 수 없는 사용자 :

생성자 패턴

2009. 6. 1. 11:56 from JSP
텔레스코핑(telescoping) 생성자
public class Test {
  private final int servingSize;
  private final int servings;
  private final int calories;

  public Test( int servingSize, int servings ){
    this( servingSize, servings, 0 );
  }

  public Test( int servingSize, int servings, int calories ){
    this.servingSize = servingSize;
    this.servings = servings;
    this.calories = calories;
  }
}
매개변수값이 작을 경우에는 유용하지만 길어지면 파라메터의 용도파악이 어려움

자바빈즈패턴
public class Test {
  private int servingSize = -1;
  private int servings = 0;
  private int calories = 0;
  public Test( ){}
 
  public void setServingSize( int val ){
    servingSize = val;
  }
  public void setServings( int val ){
    servings = val;
  }
  public void setCalories( int val ){
    calories = val;
  }
}
객체 생성후 여러번의 setter 메소드를 호출하여 파라메터를 전달해야만 사용가능한 인스턴스를 생성할 수 있고 불변 클래스생성이 불가능;;

빌더패턴
public class Test {
  private final int servingSize;
  private final int servings;
  private final int calories;
 
  public static class Builder {
    private final int servingSize;
    private final int servings = 0;
    private final int calories = 0;
   
    public Builder( int val ){
      this.servingSize = val;
    }
    public Builder servings( int val ){
      this.servings = val;
      return this;
    }
    public Builder calories( int val ){
      this.calories = val;
      return this;
    }
    public Test build(){
      return new Test(this);
    }
  }
  private Test(Builder builder){
    servingSize = builder.servingSize;
    servings = builder.servings;
    calories = builder.calories;
  }
}
사용법::
Test a = new Test.Builder(1).servings(1).calories(1).build();

생성자에 많은 매개변수가 필요할 경우 유용함
Posted by 윤재현 :