OAF- Invoke (SQL) PreparedStatement From Controller

     if(pageContext.getParameter("invokePSBtn")!=null)
               {
               String enameStr = null, jobStr= null;
               Date hireDate=null ; 
               int salInt = 0 ; 

              String outputStr =""; 
      String empData = null;
                   String sql = "select ename, job, sal , hiredate from emp "; 
                   try {
                       Connection conn =am.getOADBTransaction().getJdbcConnection();
                      
                       PreparedStatement ps = conn.prepareStatement(sql);
                       
                       ResultSet rs = ps.executeQuery(); // vo.createRowSetIterator(" ") ; 
                       
                     EmpDynamicVOImpl vo = am.getEmpDynamicVO1(); 
                     EmpDynamicVORowImpl row = null;
                     vo.executeQuery();
                       
                          while(rs.next())              
                           {
                               enameStr = rs.getString(1).trim();
                               jobStr = rs.getString(2);
                               salInt = rs.getInt(3);
                               hireDate = rs.getDate(4);
                               outputStr +=  "Employee Info --> " + enameStr +  " JobStr --->"+ jobStr + 
                               " Salary -->"+ salInt  + " Hire Date-->"+ hireDate ;
                               System.out.println("Employee Info --> " + enameStr +  " JobStr --->"+ jobStr + 
                               " Salary -->"+ salInt  + " Hire Date-->"+ hireDate);
                               
                               
                              empData =  "Employee Info --> " + enameStr +  " JobStr --->"+ jobStr + 
                               " Salary -->"+ salInt  + " Hire Date-->"+ hireDate
                                ;
                                
                                row = (EmpDynamicVORowImpl)vo.createRow();
                                row.setNewRowState(row.STATUS_INITIALIZED);
                                row.setempDataStr(empData);
                                vo.insertRow(row);
                           }

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

Leave a Reply

Your email address will not be published.