블로그 이미지
세피롯스

calendar

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

Notice

Tag

2010. 2. 24. 15:41 초보프로그래머만..

어떤내용을 디비에 저장할때 기존에 있는내용을 update할지 새로 저장할지 판단해야할때 쓰면 좋을듯..

-----------------------------------------------------------------------------------------
if not exists(select * from schedule_info_tbl where scDate = convert(datetime, '2010-02-26 13:22:11',120))

begin
 insert into schedule_info_tbl(scName,scDate)
 values('열심히', convert(datetime, '2010-02-26 13:22:11',120))
end
else
begin
 update schedule_info_tbl
 set scName = '열심히'
 where scDate = convert(datetime, '2010-02-26 13:22:11',120)
end

posted by 세피롯스
2010. 2. 22. 10:49 초보프로그래머만..

특정날짜구하기같은 경우 쿼리로 구해오는 경우가 많은데
어떨땐 자바에서 구해야할때가 있다.
입력받은날짜로 해당주의 날짜구하기 (ex. 20100203의 경우 20100201,20100202,20100202,20100203,20100204,20100205,20100206,20100207를 스트링배열로 리턴받음)


public String[] weekCalendar(String yyyymmdd) throws Exception{
  
  Calendar cal = Calendar.getInstance();
  int toYear = 0;
  int toMonth = 0;
  int toDay = 0;
  if(yyyymmdd == null || yyyymmdd.equals("")){   //파라메타값이 없을경우 오늘날짜
   toYear = cal.get(cal.YEAR); 
   toMonth = cal.get(cal.MONTH)+1;
   toDay = cal.get(cal.DAY_OF_MONTH);
   
   int yoil = cal.get(cal.DAY_OF_WEEK); //요일나오게하기(숫자로)

   if(yoil != 1){   //해당요일이 일요일이 아닌경우
    yoil = yoil-2;
   }else{           //해당요일이 일요일인경우
    yoil = 7;
   }
   cal.set(toYear, toMonth-1, toDay-yoil);  //해당주월요일로 세팅
  }else{
   int yy =Integer.parseInt(yyyymmdd.substring(0, 4));
   int mm =Integer.parseInt(yyyymmdd.substring(4, 6))-1;
   int dd =Integer.parseInt(yyyymmdd.substring(6, 8));
   cal.set(yy, mm,dd);
  }
  String[] arrYMD = new String[7];
  
  int inYear = cal.get(cal.YEAR); 
  int inMonth = cal.get(cal.MONTH);
  int inDay = cal.get(cal.DAY_OF_MONTH);
  int yoil = cal.get(cal.DAY_OF_WEEK); //요일나오게하기(숫자로)
  if(yoil != 1){   //해당요일이 일요일이 아닌경우
      yoil = yoil-2;
   }else{           //해당요일이 일요일인경우
      yoil = 7;
   }
  inDay = inDay-yoil;
  for(int i = 0; i < 7;i++){
   cal.set(inYear, inMonth, inDay+i);  //
   String y = Integer.toString(cal.get(cal.YEAR)); 
   String m = Integer.toString(cal.get(cal.MONTH)+1);
   String d = Integer.toString(cal.get(cal.DAY_OF_MONTH));
   if(m.length() == 1) m = "0" + m;
   if(d.length() == 1) d = "0" + d;
   
   arrYMD[i] = y+m +d;
   System.out.println("ymd ="+ y+m+d);
   
  }
  
  return arrYMD;
 }

posted by 세피롯스
2010. 2. 18. 16:59 초보프로그래머만..

보통은 셀렉트해올때 리턴되는 값이 고정적이지만..(ex. select a.id,a.name from table_a)
하다보면 동적인 리턴값을 가져와야할때가 있다.
아이바티스에서 리턴 컬럼이 동적일때(isnotEmpty등을 쓸경우) remapResult = "true"라고 해줘야 리턴 컬럼을 동적으로 보내준다.

(예)
<statement id="timeList" resultClass="ArrayList" remapResult = "true">
select
a.id,
a.name,
<isNotEmpty property="time">
a.time = #time#,
</isNotEmpty>
a.contents
from a
</statement>


posted by 세피롯스
2010. 2. 18. 16:57 초보프로그래머만..


An error occurred at line: 22 in the generated java file
The return type is incompatible with JspSourceDependent.getDependants()

자바개발중 콘솔창에 

위와 같은 에러가 발생했다면 jar파일을 바꿔봐라...

getDependants메소드의 리턴타입이 다르다는데...JspSourceDependent클래스를 갖고있는jar파일에서 생기는문제인듯싶다..

나의 경우엔 jasper-runtime.jar파일이 lib에 있었는데 위와같은 에러가 발생했다...

jasper-runtime.jar를 지우고 jaxp-api.jar파일로 바꿨더니 제대로 나왔다는...

 

정확한 설명은 누가 리플로 좀 올려주세요..ㅠㅠ


posted by 세피롯스
2010. 2. 18. 16:56 초보프로그래머만..

http://localhost:8080/pjName   실행하는데 창이 그냥 닫히는현상이 생겼다.

어제까지 아무이상없었는데 음...

 

근데 http://127.0.0.1:8080/pjName 로하니까 잘 나오네...

 

OS업데이트하고 보안관련되서  localhost로 웹에 입력할때 막히는게 추가된건지...잘모르겟군;;

 

구글링해보니 누군가 곰플레이어를 깔다가 잡다한것들도 같이깔아서 생긴문제일수도 있단말에(하필 그날 곰플레이어를 깔았네;;;) 혹시나해서 곰플도 지웠다

 

그래도 안되나 싶더니 한참후에 실행해보니 언제그랬냐는듯 잘 나온다;;;;

 

결국 이유도 모르고 해결ㅡㅡ;;;;

 

------------------------------------------------------------------

 

ㅎㅎ 또 이런현상이 나왔다;;;

툴바를 설치하면 ie7에선 localhost로 입력할때 보안쪽(?)에 충돌이 생기는건지 창이 닫힌다고한다.

 

툴바를 제거하자!!!!


posted by 세피롯스
2010. 2. 18. 16:55 초보프로그래머만..

자바client와 C server와의 소켓통신

 

값은 바이트로 주고 받았다.

 

자바client에서 값을 보내는 메소드이다.

8바이트를 보내줘야하는데 4바이트에는 입력받은 data값을 나머지 4바이트에는 숫자 0을 바이트로 변환하여 보냈다.(C server에서 그렇게 받아야한대서;;;)

 

 public synchronized void sendData(int data)throws Exception {   //system.in으로 입력받은 int값을 파라메터로

  OutputStream os = socket.getOutputStream();

  int bodylen = 0;
  try{
   byte[] byte_arr = new byte[8];
   byte_arr[0] = (byte) (bodylen & 0x000000FF);
   byte_arr[1] = (byte) ((bodylen >> 8) & 0x000000FF);
   byte_arr[2] = (byte) ((bodylen >> 16) & 0x000000FF);
   byte_arr[3] = (byte) ((bodylen >> 24) & 0x000000FF);
  
   byte_arr[4] = (byte) (data & 0x000000FF);
   byte_arr[5] = (byte) ((data >> 8) & 0x000000FF);
   byte_arr[6] = (byte) ((data >> 16) & 0x000000FF);
   byte_arr[7] = (byte) ((data >> 24) & 0x000000FF);

 

   //요건 제대로 바이트로 변환됐는데 확인차원에서 되돌려본것임

   int temp;
   temp = (int)byte_arr[0] & 0x000000FF;
   temp |= ((int)byte_arr[1] << 8) & 0x0000FF00;
   temp |= ((int)byte_arr[2] << 16) & 0x00FF0000;
   temp |= ((int)byte_arr[3] << 24) & 0xFF000000;

   temp |= (int)byte_arr[4] & 0x000000FF;
   temp |= ((int)byte_arr[5] << 8) & 0x0000FF00;
   temp |= ((int)byte_arr[6] << 16) & 0x00FF0000;
   temp |= ((int)byte_arr[7] << 24) & 0xFF000000;
  
   System.out.println("temp byte[] to int : "+temp);   //확인차원에서

 

   BufferedOutputStream buwriter = new BufferedOutputStream(os);
 

  buwriter.write(byte_arr);   //바이트배열을 write
  buwriter.flush();


  }catch(Exception e1){

   e1.printStackTrace();
  }
 
 }

 

이제 제대로 보내졌으니 server에서 받아온 데이터를 읽어들인다.

12바이트로 8바이트는 헤더이고 4바이트가 내가 실제 받기원하는값이다.

private void receiveData() {
  try {
 
    InputStream is = socket.getInputStream();
    DataInputStream data = new DataInputStream(is);
   
    byte[] by = new byte[12];
    data.read(by);    //바이트배열로 읽어들임


    //C에서 받는 바이트배열은 바이트오더가 반대라나??

   //그래서 11,10,9,8순서로 변환햇다
       long l = 0;
       l |= by[3] & 0xFF;
       l <<= 8;
       l |= by[2] & 0xFF;
       l <<= 8;
       l |= by[1] & 0xFF;
       l <<= 8;
       l |= by[0] & 0xFF;

    long l1 = 0;
       l1 |= by[7] & 0xFF;
       l1 <<= 8;
       l1 |= by[6] & 0xFF;
       l1 <<= 8;
       l1 |= by[5] & 0xFF;
       l1 <<= 8;
       l1 |= by[4] & 0xFF;

    long l2 = 0;
       l2 |= by[11] & 0xFF;
       l2 <<= 8;
       l2 |= by[10] & 0xFF;
       l2 <<= 8;
       l2 |= by[9] & 0xFF;
       l2 <<= 8;
       l2 |= by[8] & 0xFF;
 
  
    System.out.println("첫번째4바이트변환값 : "+ l);

    System.out.println("두번째4바이트변환값 : "+ l1);

    System.out.println("세번째4바이트변환값 : "+ l2);

  
  } catch(Exception e) {e.printStackTrace();}
 }

 

자바랑 C랑 소켓통신 드럽게 어렵네ㅠㅜ


posted by 세피롯스
2010. 2. 17. 14:27 초보프로그래머만..


플렉스 처음으로 배워보고 간단하게 짜본 계산기이다.
어디 참고도 안되겠지만 이거라도 아쉬운(?)사람들을 위해..ㅠ(나같은사람)

[Calculator.mxml 파일소스]

 

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" fontSize="12">
<mx:Script>
 <![CDATA[
  import mx.controls.Alert;
  var temp:Number = 0, total:Number = 0;
  var calc:String = "";
  var calcChk:Boolean = false; //+,-,*,/클릭후 숫자클릭시 초기화체크여부
  
  
  public function b_plus():void{
   temp = Number(show.text);
   calc = "plus";
   calcChk = true; //
  }
  public function b_minus():void{
   temp = Number(show.text);
   calc = "minus";
   calcChk = true;
  }
  public function b_gob():void{
   temp = Number(show.text);
   calc = "gob";
   calcChk = true;
  }
  public function b_divide():void{
   temp = Number(show.text);
   calc = "divide";
   calcChk = true;
  }
  public function b_equals():void{
   if(show.text != "" && calc != ""){
    if(calc == "plus"){
     total = temp + Number(show.text);
     show.text = String(total);
    }else if(calc == "minus"){
     total = temp - Number(show.text);
     show.text = String(total);
    }else if(calc == "gob"){
     total = temp * Number(show.text);
     show.text = String(total);
    }else if(calc == "divide"){
     total = temp / Number(show.text);
     show.text = String(total);
    }
   }
   
   //초기화
   temp = 0;
   calc = "";
  }
  public function chk(num:String):void{
   //숫자0먼저 누른후 다른숫자 눌럿을경우 0은 지우기
   if(show.text == "0"){
    show.text = num;
    return;
   }
   //+,-,*,/버튼을 누른후에 누르면 text창을 초기화
   if(calcChk == true){
    show.text = num;
    calcChk = false;
   }else{
    show.text = show.text + num; 
   }
  }
 ]]>
</mx:Script>
 <mx:Panel layout="absolute" title="계산기" width="310" x="100" height="301" y="100">
  <mx:Button x="37" y="124" label="4" id="a4" click="chk('4')"/>
  <mx:Button x="158" y="124" label="6" id="a6" click="chk('6')"/>
  <mx:Button x="225" y="124" label="-" fontSize="12" id="minus" click="b_minus()"/>
  <mx:Button x="225" y="219" label="/" id="divide" click="b_divide()"/>
  <mx:Button x="225" y="172" label="*" id="gob" click="b_gob()"/>
  <mx:Button x="225" y="83" label="+" id="plus" click="b_plus()"/>
  <mx:Button x="158" y="172" label="9" id="a9" click="chk('9')"/>
  <mx:Button x="98" y="172" label="8" id="a8" click="chk('8')"/>
  <mx:Button x="98" y="124" label="5" id="a5" click="chk('5')"/>
  <mx:Button x="37" y="172" label="7" id="a7" click="chk('7')"/>
  <mx:Button x="158" y="83" label="3" id="a3" click="chk('3')"/>
  <mx:Button x="37" y="219" label="0" id="a0" click="chk('0')"/>
  <mx:Button x="98" y="83" label="2" id="a2" click="chk('2')"/>
  <mx:Button x="37" y="83" label="1" id="a1" click="chk('1')"/>
  <mx:Button x="158" y="219" label="=" width="40" id="equals" click="b_equals()"/>
  <mx:TextInput x="38" y="53" id="show"  textAlign="right" width="227" text="0"/>
  <mx:Button x="98" y="219" label="C" click="show.text = '0'"/>
 </mx:Panel>
</mx:Application>


posted by 세피롯스
2010. 2. 17. 14:24 초보프로그래머만..
자바에서 여러가지방법으로 날짜를 구할수있지만 그중에서 SimpleDateFormat을 이용해 구해봤다.

 java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyyMMdd", java.util.Locale.KOREA);
  
    java.util.Date dDate = new java.util.Date();
    dDate = sdf.parse("20090901");   <-- 20090901은 입력받은날짜
    String sToday = sdf.format(dDate);
    long lCurTime = dDate.getTime();
    dDate = new java.util.Date(lCurTime+(1000*60*60*24*-1));

     String sYesterDay = sdf.format(dDate);      <--전날

    dDate = new java.util.Date(lCurTime+(1000*60*60*24*+1);

     String sTomorrow = sdf.format(dDate);       <--다음날

posted by 세피롯스
2009. 4. 29. 18:03 초보프로그래머만..

**************get방식 한글깨짐 현상****************

java script상에서.... encodeURIComponent(value); encodeURI,escape

비즈니스로직(java)상에서........... URLEncoder.encode(value)

posted by 세피롯스
2009. 4. 29. 18:00 초보프로그래머만..

보통은 셀렉트해올때 리턴되는 값이 고정적이지만..(ex. select a.id,a.name from a)
하다보면 동적인 리턴값을 가져와야할때가 있다.
아이바티스에서 리턴 컬럼이 동적일때(isnotEmpty등을 쓸경우) remapResult = "true"라고 해줘야 리턴 컬럼을 동적으로 보내준다.

(예)
<statement id="timeList" resultClass="ArrayList" remapResult = "true">
select
a.id,
a.name,
<isNotEmpty property="time">
a.time = #time#,
</isNotEmpty>
a.contents
from a
</statement>


posted by 세피롯스
prev 1 2 3 next