2013-06-06 63 views
0
public static String DuStatusinactiveanddeactive(EmpBean empBeanObj, 
               ClaimDetailsBean claimDetailsBean, 
               HttpServletRequest request) throws SQLException { 
     // To get Employee Details from cdm master 




     String query = "update GEMS_DELIVERY_UNIT set isActive=? , TRANS_USER=? where DU_ID=?"; 
     Connection conn = null; 
     conn = DAO.getMsSqlConnection(); 
     PreparedStatement stmt = null; 
     //System.out.println("came into upgradeClaim"+beanObj.getAppr1Id()+"-->"+beanObj.getAppr2Id()+"-->"+beanObj.getAwaitingAppr()+"-->"+beanObj.getClaimStatus()+"-->"+beanObj.getClaimId()); 
     try{ 
      stmt = (PreparedStatement) conn.prepareStatement(query); 
      stmt.setString(1,claimDetailsBean.getDustatus()); 
      System.out.println("ss"+claimDetailsBean.getDustatus()); 
      stmt.setString(2,empBeanObj.getEmpId()); 
       System.out.println("emp"+empBeanObj.getEmpId()); 

      stmt.setString(3,claimDetailsBean.getDucode()); 
       System.out.println("ducode"+claimDetailsBean.getDucode()); 









//where du_id=arr[0]; 


      System.out.println(query); 
      stmt.executeUpdate(); 
     }catch(Exception e){ 
      e.printStackTrace(); 
      return "fail"; 
     } 
     return "Success"; 





    } 

now stmt.setString(3,claimDetailsBean.getDucode());來自動作方法值#1的值我需要拆分這個(值#1)並且只更新查詢值。我不想要#1 如何拆分和更新請任何一個幫助?如何分割值並更新查詢

回答

0

,你可以簡單地使用分割功能的Java

public String[] split(String regex, int limit) 

public String[] split(String regex) 
+0

請給我代碼我需要這個代碼 – arulmozhi

+0

可以解釋更多,你正在尋找什麼.. – blganesh101

+0

stmt.setString(3,claimDetailsBean.getDucode());這個地方如何拆分getDucode()? – arulmozhi

0

您可以使用子

claimDetailsBean.getDucode().substring(0, claimDetailsBean.getDucode().indexOf("#")) 

你可以拿出claimDetailsBean.getDucode()在單獨的變量並且在DuCode可以爲null的情況下肯定檢查爲空。

+0

嗨Harish我需要完整的編碼 – arulmozhi

+0

String duCode = claimDetailsBean.getDucode(); (duCode!= null) \t if(duCode!= null) \t \t duCode.substring(0,duCode.indexOf(「#」)); –

+0

String duCode = claimDetailsBean.getDucode(); \t if(duCode!= null){ \t \t String value = duCode.substring(0,duCode.indexOf(「#」)); \t \t stmt.setString(3,value)); \t} –