调用start()方法时出现空指针异常

时间:2015-02-10 16:25:03

标签: java

请帮忙,因为我在onEndCall方法中得到空指针异常,请参考下面的代码

公共类GET_END_DETAILS扩展了Thread实现的EndCallInterface {

public String strCallId= "";
public String strVxmlServerIp= "";
public String strCli= "";
public String strDnis= "";
public String strCallStDateTime="";
public String strCallEndDateTime="";

public Connection conn; 
public CallableStatement SQLStm;
//public ResultSet rs=null;
public int res;

public CallEndAPI callEndAPI;

Thread t;

public void onEndCall(CallEndAPI callEndAPI) throws AudiumException{
    try{

//设置来电结束日期时间

        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");//24hrs
        Date date = new Date();
        strCallEndDateTime=dateFormat.format(date);

        callEndAPI.addToLog("Call End Time : ", strCallEndDateTime);

        callEndAPI.setSessionData("S_CALL_ENDDATETIME", strCallEndDateTime);

        strCallId= callEndAPI.getSessionData("CallID").toString();

        callEndAPI.addToLog("CallID : ", strCallId);

        strVxmlServerIp= callEndAPI.getSessionData("S_VXMLSERVER_IP").toString();

        callEndAPI.addToLog("Vxml Server IP : ", strVxmlServerIp);
        strCli=callEndAPI.getSessionData("S_ANI").toString();

        callEndAPI.addToLog("CLI : ", strCli);


        strDnis=callEndAPI.getSessionData("S_DNIS").toString();

        callEndAPI.addToLog("DNIS : ", strDnis);

        strCallStDateTime=callEndAPI.getSessionData("S_CALL_STARTDATETIME").toString();



        callEndAPI.addToLog("Call Start Time : ", strCallStDateTime);

        //callEndAPI.addToLog("Call End :", "Call ID=" + sCID );



            callEndAPI.addToLog("Starting the Java Thread to insert values into EWT table","");

            t.start();




        }catch (Exception e){
        callEndAPI.addToLog("Call End Exception: ", e.getMessage().toString());

    }

}

public void run(){

    try{
        callEndAPI.addToLog("Inside run() method","");
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        conn = DriverManager.getConnection("jdbc:sqlserver://172.18.150.154;user=ivr_user;password=aircel123;database=AircelInterimReport");
        //Statement SQLStm= conn.createStatement(); 
        //String sSQL="insert into CALL_END_DETAILS_EWT (CALL_ID,VXMLSERVER_IP) values ('" + sCID + "','" + sVxmlIP + "')";

        String sSQL="{call LOG_CALLEND_DETAILS_EWT(?, ?, ?, ?, ?, ?)}";

        SQLStm= conn.prepareCall(sSQL);

        SQLStm.setString(1, strCallId);
        SQLStm.setString(2, strVxmlServerIp);
        SQLStm.setString(3, strCli);
        SQLStm.setString(4, strDnis);
        SQLStm.setString(5, strCallStDateTime);
        SQLStm.setString(6, strCallEndDateTime);

        callEndAPI.addToLog("Call End : ", "Insert Statement " + sSQL);
        res =SQLStm.executeUpdate();

        callEndAPI.addToLog("","Values inserted to EWT SQL table successfully");




        /*int res;
        res=Call_Log_EWT(sCID,"172.18.150.66" , "121313", "4555");

        if(res>0)
            callEndAPI.addToLog("Call End API", "Database Connection successfull and Table Record Count is : " + res);

        else
            callEndAPI.addToLog("Call End API", "Database Connection failed");*/

    }catch(Exception e){
        callEndAPI.addToLog("Exception occured",e.getMessage().toString());
    }


finally
{
    try
    {

        conn.close();

        SQLStm.close();

    }
    catch(SQLException sqlEx)
    {
        callEndAPI.addToLog("SQL Exception while closing connection : "  , sqlEx.getMessage().toString());
    }
}

} }

0 个答案:

没有答案
相关问题