Forum Stats

  • 3,768,917 Users
  • 2,252,874 Discussions
  • 7,874,797 Comments

Discussions

SMS Attendance Program

Hi Java Experts,

Your help would be grateful to me.

Below I have mentioned the exact requirement, It is quite related to Java Performance Tuning.

Note: I analyzed the code but I don't think it's code performance problem. Please notify me if any.

Overview of program: This program is used to send sms to the employees whose attendance is not marked as of day.

Issue: Program is scheduled at 4pm everyday but sends SMS to employees after 11pm. Since there is a performance issue this needs to be looked at.

Moreover there is another change that needs to be incorporated. If someone runs this program manually despite of the schedule, the program should be executed only if concurrent request start time is or after 4pm.

Ex. Program is run manually at 11 am : Doesnot execute and SMS is not send to employees

    Program is run manually at/after 4 pm : Executes and SMS is send to employees

============================================================================================================

package oracle.apps.ben.selfservice.sms;

import java.io.*;

import java.sql.*;

import java.util.*;

import java.net.*;

import java.net.MalformedURLException;

import oracle.apps.fnd.util.*;

import oracle.apps.fnd.cp.request.*;

public class InvokeSmsURL implements JavaConcurrentProgram {   

public void runProgram(CpContext pCpContext)   

{        

  ReqCompletion lRC = pCpContext.getReqCompletion();

         String CompletionText = "";

    Vector sendvec = new Vector();

  try {

                sendvec = getPhoneNumber();

                int veclen = sendvec.size();

   for(int loop=0;loop<veclen;loop=loop+3)

                {

  URL myURL = new URL("http://axiom.axisb.com:4001/axiomhttprec/pushlistener?dcode=HRMSALERTS&userid=idhrmsalerts&pwd=pahrmsalerts123&ctype=1&alert=0&msgtype=S&priority=4&sender=AxisBk&pno="+(String)sendvec.elementAt(loop+1)+"&msgtxt=Emp+"+(String)sendvec.elementAt(loop)+"+-+You+have+not+marked+your+attendance/leave+on+HRMS+for+"+(String)sendvec.elementAt(loop+2)+".+You+are+requested+to+make+corrective+actions+for+the+same.");

      URLConnection myURLConnection = myURL.openConnection();

    myURLConnection.connect();

  BufferedReader in = new BufferedReader(

                                new InputStreamReader(

                                myURLConnection.getInputStream()));

        String inputLine;

        while ((inputLine = in.readLine()) != null)

            System.out.println(inputLine);

        in.close();

                System.out.println(myURL);

  }

            }

           

   catch (MalformedURLException e) {     // new URL() failed

  System.out.println("Malformed Exception"+e);

    }

   catch (IOException e) {               // openConnection() failed

  System.out.println("IO Exception"+e);

  }

  catch (Exception e) {               // openConnection() failed

                System.out.println("IO Exception"+e);

                                        }

            finally {

                System.out.println("finally");

            }

          lRC.setCompletion(ReqCompletion.NORMAL, CompletionText);

     }

      public Connection getVIS2Connection()

        {     

                Connection conn=null;

                 try{

                Class.forName("oracle.jdbc.driver.OracleDriver");

               

                conn = DriverManager.getConnection("jdbc:oracle:thin:@10.0.24.234:1521:hraxis","apps","all15w3ll");

               

                }catch(Exception e)

                {

                        System.out.println(e);

                }

                return conn;

        }

public  Vector getPhoneNumber() throws IOException,SQLException

         {

                      Connection con = null;

                      PreparedStatement pstmt = null;

                      ResultSet rset = null;

                      String mobile = null;

                      String empno = null;

  String absence_date = null;

String sqlquery = "select * from axis_hr_attendance_sms_view where empno not in '47224'";

                        Vector v = new Vector();

                                   try

                                   {

                                        con = getVIS2Connection();

                                        pstmt = con.prepareStatement(sqlquery);

                                        rset = pstmt.executeQuery();

                                        while(rset.next())

                                        {

                                                empno = rset.getString("empno");

                                                mobile = rset.getString("mobile_no");

  absence_date = rset.getString("absence_date");

                                                v.add(empno);

                                                v.add(mobile);

  v.add(absence_date);

                                      

                                        }

                                    }

                                   catch(Exception e)

                                   {

                                        System.out.println(e);

                                   }

                                   finally

                                   {

                                       try{

                                          if(rset!=null)

                                                rset.close();

                                          pstmt.close();

                                          con.close();

                                          }

                                        catch(SQLException sql)

                                          {}

                                   }

           return v;

        }

}

============================================================================================================

Please update me.

Thanks,

Datta Bachate