2012년 4월 30일 월요일

ibatis procedure call

<parameterMap id="myParamMap" class="java.util.Map"> 
<parameter property="username" mode="IN" /> 
<parameter property="roles1" jdbcType="ORACLECURSOR" mode="OUT" /> 
<parameter property="roles2" jdbcType="ORACLECURSOR" mode="OUT" /> 
<parameter property="roles3" jdbcType="ORACLECURSOR" mode="OUT" /> 

</parameterMap

2012년 4월 26일 목요일

procedure SimpleJdbcCall


String procedureName = "procedure name";

this.procCall = new SimpleJdbcCall(jdbcTemplate)
                  .withProcedureName(procedureName)
                  .withoutProcedureColumnMetaDataAccess()
                  .useInParameterNames("year","buildId","ofSavings")
           
                  .declareParameters(
                new SqlParameter("",Types.VARCHAR),
                new SqlParameter("",Types.VARCHAR),
                new SqlParameter("",Types.VARCHAR),
                new SqlOutParameter("",Types.VARCHAR),
                new SqlOutParameter("",Types.VARCHAR));


Map in  = new HashMap<String,Object>();

in.put("parameter Id", parameterValue);
in.put("parameter Id", parameterValue);
in.put("parameter Id", parameterValue);
in.put("parameter Id",  parameterValue );
in.put("parameter Id",  parameterValue);
                 
Map out = procCall.execute(in);

return out;

jQuary Ajax Sample dataType 'json'


$.ajax({
    type: "POST",
    url: "<ContextRoot>/ajaxcall.dol",
    data: param,
    dataType: 'json',
    success: function(result){
     alert ("success");
      var count = result.data.length;

                   var sampleData = result.data[?].?????;
     
    },
    error: function() {
    alert("호출에 실패했습니다.");
    }
    });


@Controller
public Class SampleController {

    @Requestmapping (value="ajaxcall.do",method=RequestMethod.POST)

    public String  sampleHandle (){
      Map <String,Object> resultMap = new HashMap<String,Object>();
     
      // method Function Start
      // method Result Value
       
         resultMap.put ("data",Object);
      // method Function end


      String returnValue =  util.buildJson((HashMap) resultMap);
      return returnValue;
   }
}