document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. package com.enzen.cis.dao;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.PreparedStatement;
  5. import java.sql.ResultSet;
  6. import java.sql.SQLException;
  7. import java.sql.Statement;
  8. import java.text.SimpleDateFormat;
  9. import java.util.ArrayList;
  10. import java.util.Calendar;
  11. import java.util.Date;
  12.  
  13. import com.enzen.cis.bean.Consumer;
  14. import com.enzen.cis.bean.DomainTypeBean;
  15.  
  16. public class DAOConsumerAddEdit {
  17.  
  18.     String  strdateVar,strdateVar1;
  19.     int nCurrentUser=1;
  20.     Date dtVar;
  21.     SimpleDateFormat df2=new SimpleDateFormat("dd-MMM-yyyy");
  22.     Date dtd2;
  23.     Calendar dtd4=Calendar.getInstance();
  24.    
  25.      SimpleDateFormat formatter=
  26.           new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
  27.     java.sql.Date sqlDate;
  28.    
  29.     private ArrayList<DomainTypeBean> dtList=new ArrayList<DomainTypeBean>();
  30.  
  31.     public void setDtList(ArrayList<DomainTypeBean> dtList) {
  32.  
  33.         this.dtList = dtList;
  34.  
  35.     }
  36.  
  37.     public ArrayList<DomainTypeBean> getDtList() {
  38.  
  39.         try{
  40.  
  41.             Connection con= DBConnector.getConnection();
  42.  
  43.             if (con != null){
  44.  
  45.                 String strQuery1=("select domain.description,domain.objectid from domain inner join domaintype on (domain.domaintype_oid=domaintype.objectid) where domaintype.code=\'STATUS\'");
  46.  
  47.                 Statement st = con.createStatement();
  48.                 ResultSet rs=st.executeQuery(strQuery1);
  49.                 System.out.println("Before while loop");
  50.                 while (rs.next()){
  51.  
  52.                     DomainTypeBean bean=new DomainTypeBean();
  53.                     bean.setDescription(rs.getString("description"));
  54.                     bean.setObjid(rs.getInt("objectid"));
  55.                     dtList.add(bean);
  56.  
  57.                 }
  58.                 System.out.println(dtList);
  59.             }
  60.  
  61.  
  62.         }
  63.         catch(Exception e){
  64.             e.printStackTrace();
  65.         }
  66.  
  67.         return dtList;
  68.  
  69.     }
  70.  
  71.     public int InsertionDB (Consumer bean) throws Exception{
  72.         Connection con = null;
  73.         PreparedStatement stmt = null;
  74.         PreparedStatement stmt1 = null;
  75.         PreparedStatement stmt2 = null;
  76.         ResultSet rs = null;
  77.         int nconsumer_id=0;
  78.        
  79.        
  80.         try {
  81.             con= DBConnector.getConnection();
  82.             con.setAutoCommit(false);
  83.            
  84.             String query= "INSERT INTO DB_CONSUMER (WENEXA_ID,RR_NO,CONSUMER_NAME,RESIDING_VILLAGE,CONTACT_NO, CONTACT_PERSON,REP_DATE,STATUS_ID) VALUES (?,?,?,?,?,?,?,?)";
  85.             stmt = con.prepareStatement(query);
  86.             stmt.setString(1, bean.getWenexa_id());
  87.             stmt.setString(2, bean.getRr_number());
  88.             stmt.setString(3, bean.getConsumer_name());
  89.             stmt.setString(4, bean.getResiding_village());
  90.             stmt.setString(5,bean.getContact_no());
  91.             stmt.setString(6,bean.getContact_person());
  92.            
  93.             if(bean.getRep_date()==null||bean.getRep_date()==""){
  94.                 bean.setRep_date(null);
  95.             }
  96.             if(bean.getRep_date()!=null){
  97.                 System.out.println("DAte before Insert"+bean.getRep_date());
  98.                 dtd2= df2.parse(bean.getRep_date());
  99.                 sqlDate = new java.sql.Date(dtd2.getTime());
  100.  
  101.             }
  102.             stmt.setDate(7, (java.sql.Date) sqlDate);
  103.             stmt.setInt(8,bean.getStatus());
  104.             stmt.executeUpdate();
  105.        
  106.        
  107.            
  108.             String query2="select max(consumer_id) as consumer_id from db_consumer";
  109.             stmt2 = con.prepareStatement(query2);
  110.             rs= stmt2.executeQuery();
  111.             while (rs.next()){
  112.             nconsumer_id=(rs.getInt("consumer_id"));
  113.             }
  114.             bean.setConsumer_id(nconsumer_id);
  115.             String query1="INSERT INTO DB_CONSUMER_HISTORY (WENEXA_ID,RR_NO,CONSUMER_NAME,RESIDING_VILLAGE,CONTACT_NO, CONTACT_PERSON,REP_DATE,STATUS_ID,MODIFIED_BY,MODIFIED_DATE,CONSUMER_ID) VALUES (?,?,?,?,?,?,?,?,?,now(),?)";
  116.             stmt1 = con.prepareStatement(query1);
  117.             stmt1.setString(1, bean.getWenexa_id());
  118.             stmt1.setString(2, bean.getRr_number());
  119.             stmt1.setString(3, bean.getConsumer_name());
  120.             stmt1.setString(4, bean.getResiding_village());
  121.             stmt1.setString(5,bean.getContact_no());
  122.             stmt1.setString(6,bean.getContact_person());
  123.             if(bean.getRep_date()==null||bean.getRep_date()==""){
  124.                 bean.setRep_date(null);
  125.             }
  126.             if(bean.getRep_date()!=null){
  127.                 System.out.println("DAte before Insert"+bean.getRep_date());
  128.                 dtd2= df2.parse(bean.getRep_date());
  129.                 sqlDate = new java.sql.Date(dtd2.getTime());
  130.             }
  131.             stmt1.setDate(7, (java.sql.Date) sqlDate);
  132.             stmt1.setInt(8,bean.getStatus());
  133.             stmt1.setInt(9,nCurrentUser);
  134.             stmt1.setInt(10,bean.getConsumer_id());
  135.             stmt1.executeUpdate();
  136.             con.commit();                              
  137.         }
  138.         catch (Exception sqe) {
  139.             sqe.printStackTrace();
  140.            
  141.             try {
  142.                 //An error occurred so we roll back the changes.
  143.                 con.rollback();
  144.             } catch (SQLException ex1) {
  145.                 ex1.printStackTrace();
  146.             }
  147.            
  148.            
  149.         } finally {
  150.  
  151.            
  152.             DBConnector.closeStatement(stmt);
  153.             DBConnector.closeConnection(con);
  154.         }
  155.         return nconsumer_id;
  156.     }
  157.  
  158.  
  159.     public  Consumer obtainConsumerData(int consumer_id) throws Exception {
  160.         Connection con = null;
  161.         PreparedStatement stmt = null;
  162.         ResultSet rs = null;
  163.         Consumer bean =new Consumer();
  164.  
  165.         try {
  166.             con= DBConnector.getConnection();
  167.             if (con != null){
  168.                 String query="SELECT CONSUMER_ID,WENEXA_ID,RR_NO,CONSUMER_NAME,RESIDING_VILLAGE,CONTACT_NO,CONTACT_PERSON, to_char(REP_DATE, \'DD-Mon-YYYY\') REP_DATE ,STATUS_ID FROM db_consumer WHERE CONSUMER_ID="+consumer_id ;
  169.                 stmt = con.prepareStatement(query);
  170.                 rs= stmt.executeQuery();
  171.                 while (rs.next()){
  172.  
  173.                     bean.setConsumer_id(rs.getInt("CONSUMER_ID"));
  174.                     bean.setWenexa_id(rs.getString("WENEXA_ID"));
  175.                     bean.setRr_number(rs.getString("RR_NO"));
  176.                     bean.setConsumer_name(rs.getString("CONSUMER_NAME"));
  177.                     bean.setResiding_village(rs.getString("RESIDING_VILLAGE"));
  178.                     bean.setContact_no(rs.getString("CONTACT_NO"));
  179.                     bean.setContact_person(rs.getString("CONTACT_PERSON"));
  180.                     bean.setRep_date(rs.getString("REP_DATE"));// Chances of conflict
  181.                     System.out.println("Before formatting"+strdateVar);
  182.                     /*
  183.                      * Coding logic
  184.                      */
  185.  
  186.                     bean.setStatus(rs.getInt("STATUS_ID"));
  187.                     System.out.println("Retreived Data"+bean.getConsumer_id()+bean.getConsumer_name()+bean.getStatus());
  188.                 }
  189.  
  190.  
  191.  
  192.             }
  193.  
  194.         } catch (SQLException sqe) {
  195.             sqe.printStackTrace();
  196.            
  197.         } finally {
  198.             DBConnector.closeResultSet(rs);
  199.             DBConnector.closeStatement(stmt);
  200.             DBConnector.closeConnection(con);
  201.         }
  202.         return bean;
  203.  
  204.     }
  205.  
  206.     public void updateDB(Consumer bean) throws Exception {
  207.         String query;
  208.         Connection con = null;
  209.         PreparedStatement stmt = null;
  210.         ResultSet rs = null;
  211.         PreparedStatement stmt1 = null;
  212.         System.out.println(bean.getConsumer_id());
  213.         System.out.println(bean.getConsumer_name());
  214.         try {
  215.             con= DBConnector.getConnection();
  216.             if (con != null){
  217.                 con= DBConnector.getConnection();
  218.                 con.setAutoCommit(false);
  219.                 System.out.println("Connected");
  220.                 if(bean.getRep_date()==null||bean.getRep_date()==""){
  221.                     bean.setRep_date(null);
  222.                 }
  223.                 /*
  224.                  * The Reason for two queries- To allow value of repdate to be passed without quotes
  225.                  * if it is NULL.
  226.                  */
  227.                 if(bean.getRep_date()!=null){
  228.                     query="UPDATE db_consumer SET WENEXA_ID=\'"+bean.getWenexa_id()+"\',RR_NO=\'"+bean.getRr_number()+"\',CONSUMER_NAME=\'"+bean.getConsumer_name()+"\',RESIDING_VILLAGE=\'"+bean.getResiding_village()+"\',CONTACT_NO=\'"+bean.getContact_no()+"\',CONTACT_PERSON=\'"+bean.getContact_person()+"\',REP_DATE=\'"+bean.getRep_date()+"\',STATUS_ID=\'"+bean.getStatus()+"\' WHERE CONSUMER_ID="+bean.getConsumer_id()+"";
  229.                 }
  230.                 else{
  231.                 query="UPDATE db_consumer SET WENEXA_ID=\'"+bean.getWenexa_id()+"\',RR_NO=\'"+bean.getRr_number()+"\',CONSUMER_NAME=\'"+bean.getConsumer_name()+"\',RESIDING_VILLAGE=\'"+bean.getResiding_village()+"\',CONTACT_NO=\'"+bean.getContact_no()+"\',CONTACT_PERSON=\'"+bean.getContact_person()+"\',REP_DATE="+bean.getRep_date()+",STATUS_ID="+bean.getStatus()+" WHERE CONSUMER_ID="+bean.getConsumer_id()+"";
  232.                 }
  233.                 System.out.println(query);
  234.                 stmt = con.prepareStatement(query);
  235.                 stmt.executeUpdate();
  236.                    
  237.                 String query1="INSERT INTO DB_CONSUMER_HISTORY (WENEXA_ID,RR_NO,CONSUMER_NAME,RESIDING_VILLAGE,CONTACT_NO, CONTACT_PERSON,REP_DATE,STATUS_ID,MODIFIED_BY,MODIFIED_DATE,CONSUMER_ID) VALUES (?,?,?,?,?,?,?,?,?,now(),?)";
  238.                 stmt1 = con.prepareStatement(query1);
  239.                 stmt1.setString(1, bean.getWenexa_id());
  240.                 stmt1.setString(2, bean.getRr_number());
  241.                 stmt1.setString(3, bean.getConsumer_name());
  242.                 stmt1.setString(4, bean.getResiding_village());
  243.                 stmt1.setString(5,bean.getContact_no());
  244.                 stmt1.setString(6,bean.getContact_person());
  245.                 if(bean.getRep_date()==null||bean.getRep_date()==""){
  246.                     bean.setRep_date(null);
  247.                 }
  248.                
  249.                 if(bean.getRep_date()!=null){
  250.                     System.out.println("DAte before Insert"+bean.getRep_date());
  251.                     dtd2= df2.parse(bean.getRep_date());
  252.                     sqlDate = new java.sql.Date(dtd2.getTime());
  253.                 }
  254.                 stmt1.setDate(7, (java.sql.Date) sqlDate);
  255.                 stmt1.setInt(8,bean.getStatus());
  256.                 stmt1.setInt(9,nCurrentUser);
  257.        
  258.            
  259.                 stmt1.setInt(10,bean.getConsumer_id());
  260.                 stmt1.executeUpdate();
  261.                 con.commit();  
  262.             }
  263.         }
  264.         catch (SQLException sqe) {
  265.             sqe.printStackTrace();
  266.            
  267.            
  268.             try {
  269.                 //An error occurred so we roll back the changes.
  270.                 con.rollback();
  271.             } catch (SQLException ex1) {
  272.                 ex1.printStackTrace();
  273.             }
  274.  
  275.         } finally {
  276.             DBConnector.closeResultSet(rs);
  277.             DBConnector.closeStatement(stmt);
  278.             DBConnector.closeConnection(con);
  279.         }
  280.     }
  281.  
  282.     public int getInsertedConsumerID() throws Exception{
  283.         Connection con = null;
  284.         PreparedStatement stmt = null;
  285.         ResultSet rs = null;
  286.         int consumer_id=0;
  287.  
  288.         try {
  289.             con= DBConnector.getConnection();
  290.             if (con != null){
  291.             String query="select max(consumer_id) as consumer_id from db_consumer";
  292.         //      String query1="select nextval(\'consumer_id_sequence\')  from db_consumer LIMIT 1";
  293.                 stmt = con.prepareStatement(query);
  294.                 rs= stmt.executeQuery();
  295.                 while (rs.next()){
  296.  
  297.                     consumer_id=(rs.getInt("consumer_id"));
  298.                 }
  299.            
  300.             }
  301.  
  302.         }
  303.         catch (SQLException sqe) {
  304.             sqe.printStackTrace();
  305.  
  306.         } finally {
  307.             DBConnector.closeResultSet(rs);
  308.             DBConnector.closeStatement(stmt);
  309.             DBConnector.closeConnection(con);
  310.         }      
  311.        
  312.         return consumer_id;
  313.     }
  314.    
  315.     /*
  316.      * In progress.
  317.      */
  318.     public ArrayList<Consumer> getConsumerList(int consumer_id) throws Exception {
  319.         ArrayList<Consumer> resultList=new ArrayList<Consumer>();
  320.         Connection con = null;
  321.         PreparedStatement stmt = null;
  322.         ResultSet rs = null;
  323.         Consumer bean;
  324.         try {
  325.             con= DBConnector.getConnection();
  326.             if (con != null){
  327.             String query="SELECT CONSUMER_ID,WENEXA_ID,RR_NO,CONSUMER_NAME,RESIDING_VILLAGE,CONTACT_NO,CONTACT_PERSON, to_char(REP_DATE, \'DD-Mon-YYYY\') REP_DATE ,coalesce(DB_EMPLOYEE.FIRST_NAME,\' \')||coalesce(DB_EMPLOYEE.MIDDLE_NAME,\' \')||coalesce(DB_EMPLOYEE.LAST_NAME,\' \') MODIFIED_BY,to_char(MODIFIED_DATE, \'DD-Mon-YYYY HH MI AM\')MODIFIED_DATE,(DOMAIN.DESCRIPTION) AS STATUS FROM db_consumer_history INNER JOIN domain on DOMAIN.OBJECTID=DB_CONSUMER_HISTORY.STATUS_ID INNER JOIN db_employee on DB_EMPLOYEE.EMP_ID=DB_CONSUMER_HISTORY.MODIFIED_BY  WHERE CONSUMER_ID="+consumer_id+" ORDER BY MODIFIED_DATE DESC";
  328.             stmt = con.prepareStatement(query);
  329.             rs= stmt.executeQuery();
  330.             while(rs.next()){
  331.                 bean =new Consumer();
  332.                 bean.setConsumer_id(rs.getInt("CONSUMER_ID"));
  333.                 bean.setWenexa_id(rs.getString("WENEXA_ID"));
  334.                 bean.setRr_number(rs.getString("RR_NO"));
  335.                 bean.setConsumer_name(rs.getString("CONSUMER_NAME"));
  336.                 bean.setResiding_village(rs.getString("RESIDING_VILLAGE"));
  337.                 bean.setContact_no(rs.getString("CONTACT_NO"));
  338.                 bean.setContact_person(rs.getString("CONTACT_PERSON"));
  339.                 bean.setRep_date(rs.getString("REP_DATE"));// Chances of conflict
  340.                 bean.setStrStatus(rs.getString("STATUS"));
  341.                 bean.setDtmodifiedDate(rs.getString("MODIFIED_DATE"));
  342.                 bean.setStrmodifiedBy(rs.getString("MODIFIED_BY"));
  343.                 resultList.add(bean);
  344.             }
  345.            
  346.             for (Consumer c:resultList){
  347.                 System.out.println(c.getConsumer_name());
  348.                 System.out.println(c.getContact_no());
  349.             }
  350.             }
  351.             }
  352.         catch (SQLException sqe) {
  353.             sqe.printStackTrace();
  354.  
  355.         } finally {
  356.             DBConnector.closeResultSet(rs);
  357.             DBConnector.closeStatement(stmt);
  358.             DBConnector.closeConnection(con);
  359.         }      
  360.        
  361.     return resultList;
  362.     }
  363.    
  364.    
  365.    
  366.     public ArrayList<Consumer> getlistedMeterDetails(int consumer_id) throws Exception {
  367.         ArrayList<Consumer> resultList=new ArrayList<Consumer>();
  368.         Connection con = null;
  369.         PreparedStatement stmt = null;
  370.         ResultSet rs = null;
  371.         int serial;
  372.         Consumer bean;
  373.         try {
  374.             con= DBConnector.getConnection();
  375.             if (con != null){
  376.             String query="SELECT db_consumer_meter_details.consumer_id as CONSUMER_ID,db_consumer_meter_details.meter_id AS  METER_ID, db_meter.meter_serial AS METER_SERIAL,DB_POLE.POLE_NUMBER AS POLE_NUMBER,db_consumer_meter_details.ACTIVE AS ACTIVE from db_consumer_meter_details INNER JOIN db_meter on DB_METER.METER_ID=db_consumer_meter_details.METER_ID INNER JOIN DB_POLE on DB_POLE.POLE_ID=db_consumer_meter_details.POLE_ID WHERE CONSUMER_ID= "+consumer_id ;
  377.             stmt = con.prepareStatement(query);
  378.             System.out.println(query);
  379.             rs= stmt.executeQuery();
  380.             while(rs.next()){
  381.                 bean =new Consumer();
  382.                 serial=rs.getRow();
  383.                 bean.setSerial(serial);
  384.                 bean.setConsumer_id(rs.getInt("CONSUMER_ID"));
  385.                 bean.setNmeterID(rs.getInt("METER_ID"));
  386.                 bean.setStrmeterSerial(rs.getString("METER_SERIAL"));
  387.                 bean.setStrpoleNumber(rs.getString("POLE_NUMBER"));
  388.                 bean.setBlactive(rs.getBoolean("ACTIVE"));
  389.                 if(bean.getBlactive()==true){
  390.                     bean.setStrstatusActive("Yes");
  391.                    
  392.                 }
  393.                 else if(bean.getBlactive()==false){
  394.                     bean.setStrstatusActive("No");
  395.                 }
  396.                 resultList.add(bean);
  397.             }
  398.             }
  399.         }
  400.         catch (SQLException sqe) {
  401.             sqe.printStackTrace();
  402.  
  403.         } finally {
  404.             DBConnector.closeResultSet(rs);
  405.             DBConnector.closeStatement(stmt);
  406.             DBConnector.closeConnection(con);
  407.         }      
  408.         for (Consumer c:resultList){
  409.             System.out.println(c.getNmeterID());
  410.            
  411.         }  
  412.     return resultList;
  413.    
  414.     }
  415.    
  416.     public void insertMeterDetails (Consumer bean) throws Exception{
  417.         Connection con = null;
  418.         PreparedStatement stmt = null;
  419.         ResultSet rs = null;
  420.         try {
  421.             con= DBConnector.getConnection();
  422.             if (con != null){
  423.                 String query= "INSERT INTO DB_CONSUMER_METER_DETAILS (CONSUMER_ID,METER_ID,POLE_ID,CREATED_DATE,CREATED_BY,REMARKS,ACTIVE)VALUES(?,?,?,now(),?,?,?) ";
  424.                 System.out.println(query);
  425.                 stmt = con.prepareStatement(query);
  426.            
  427.                 stmt.setInt(1,bean.getConsumer_id());
  428.                 stmt.setInt(2,bean.getNmeterID());
  429.                 stmt.setInt(3,bean.getNpoleID());
  430.                 stmt.setInt(4,bean.getNcreated_by());
  431.                 stmt.setString(5,bean.getStrRemarks());
  432.                 stmt.setBoolean(6, bean.getBlactive());    
  433.                 stmt.executeUpdate();
  434.             }
  435.             }
  436.         catch (Exception sqe) {
  437.             sqe.printStackTrace();
  438.  
  439.         } finally {
  440.             DBConnector.closeResultSet(rs);
  441.             DBConnector.closeStatement(stmt);
  442.             DBConnector.closeConnection(con);
  443.         }      
  444.    
  445.        
  446.     }
  447.     public  Consumer obtainMeterData(int nmeter_id) throws Exception {
  448.         Connection con = null;
  449.         PreparedStatement stmt = null;
  450.         ResultSet rs = null;
  451.         Consumer bean =new Consumer(); 
  452.         try {
  453.             con= DBConnector.getConnection();
  454.             if (con != null){
  455.                 String query="SELECT DB_CONSUMER.CONSUMER_NAME,DB_CONSUMER_METER_DETAILS.POLE_ID AS POLE_ID,DB_CONSUMER_METER_DETAILS.CONSUMER_ID AS CONSUMER_ID, DB_METER.METER_SERIAL AS METER_SERIAL,DB_POLE.POLE_NUMBER AS POLE_NUMBER,DB_CONSUMER_METER_DETAILS.ACTIVE AS ACTIVE,DB_CONSUMER_METER_DETAILS.REMARKS AS REMARKS FROM DB_CONSUMER_METER_DETAILS INNER JOIN DB_CONSUMER ON DB_CONSUMER.CONSUMER_ID=DB_CONSUMER_METER_DETAILS.CONSUMER_ID INNER JOIN DB_METER ON DB_METER.METER_ID=DB_CONSUMER_METER_DETAILS.METER_ID INNER JOIN DB_POLE ON DB_POLE.POLE_ID=DB_CONSUMER_METER_DETAILS.POLE_ID WHERE DB_CONSUMER_METER_DETAILS.METER_ID= "+nmeter_id;
  456.                 stmt = con.prepareStatement(query);
  457.                 rs= stmt.executeQuery();
  458.                 while (rs.next()){
  459.                     bean.setConsumer_name(rs.getString("CONSUMER_NAME"));
  460.                     bean.setConsumer_id(rs.getInt("CONSUMER_ID"));
  461.                     bean.setStrmeterSerial(rs.getString("METER_SERIAL"));
  462.                     bean.setStrpoleNumber(rs.getString("POLE_NUMBER"));
  463.                     bean.setBlactive(rs.getBoolean("ACTIVE"));
  464.                     bean.setStrRemarks(rs.getString("REMARKS"));
  465.                     bean.setNpoleID(rs.getInt("POLE_ID"));
  466.                     if(bean.getBlactive()==true){
  467.                         bean.setStrstatusActive("Yes");
  468.                     }
  469.                     else{
  470.                         bean.setStrstatusActive("No");
  471.                     }
  472.                 }
  473.             }
  474.         }catch (SQLException sqe) {
  475.             sqe.printStackTrace();
  476.            
  477.         } finally {
  478.             DBConnector.closeResultSet(rs);
  479.             DBConnector.closeStatement(stmt);
  480.             DBConnector.closeConnection(con);
  481.         }
  482.         return bean;
  483.  
  484.        
  485.    
  486.     }
  487.    
  488.     public void updatemeterDetails(Consumer bean,int hdnmeterid) throws Exception {
  489.         Connection con = null;
  490.         PreparedStatement stmt = null;
  491.         ResultSet rs = null;
  492.    
  493.        
  494.         try {
  495.             con= DBConnector.getConnection();
  496.             if (con != null){
  497.                 con= DBConnector.getConnection();
  498.                 String query="UPDATE DB_CONSUMER_METER_DETAILS SET CONSUMER_ID = "+bean.getConsumer_id()+ " ,METER_ID = "+bean.getNmeterID()+",POLE_ID ="+bean.getNpoleID()+ " ,ACTIVE = "+bean.getBlactive()+ ",REMARKS = \'" +bean.getStrRemarks()+ "\' WHERE METER_ID = "+hdnmeterid;
  499.                 System.out.println(query);
  500.                 stmt = con.prepareStatement(query);
  501.                 stmt.executeUpdate();
  502.             }
  503.         }
  504.         catch (SQLException sqe) {
  505.             sqe.printStackTrace();
  506.         }finally {
  507.             DBConnector.closeResultSet(rs);
  508.             DBConnector.closeStatement(stmt);
  509.             DBConnector.closeConnection(con);
  510.         }      
  511.    
  512.        
  513.        
  514.         //
  515.     }
  516.     }
');