phssubmtthread.java

来自「JAVA实现的短信网关程序」· Java 代码 · 共 137 行

JAVA
137
字号
package sms.PHS;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */
import dbconnectionbean.*;
import java.sql.*;

public class PHSSubmtThread extends Thread{
  Connection con_cp = null;
  ConnectionPoolBean beanCP;
  TestClient phsClient=null;
  public PHSSubmtThread(TestClient phsclient) {
    this.phsClient=phsclient;
  }

  public void initCon() {
       beanCP = new ConnectionPoolBean();
       beanCP.setinit();
       beanCP.setName("smgpsp");
       con_cp = beanCP.getSqlCon();
       System.out.println("(^_^)连接初始化::初始化本地网关接口数据库连接完成。" + "\n");

     }

    public void run() {
      initCon();
     String sql="select top 15 * from phs_submit where handleflag=0";
     System.out.println("下行sql:"+sql);
     System.out.println("从mt表中得到数据.下行中...");

     String id = "";
     byte nNeedReport ;
     byte nPriority ;
     String sServerId = "";
     byte nMsgFormat ;
     String sFeeType = "";
     String sFeeCode = "";
     String sFixedFee = "";
     String sValidTime = "";
     String sAtTime = "";
     String sChargeTermId = "";
     String sDestTermId = "";
     String sReplyPath = "";
     int nMsgLength =0;
     //byte[] cMsgCont ;
     String cMsgCont="";
     String nMsgType = "";
     String flag = "";
     String nsert_time = "";
     int sequenceid=0;
    try{
      Statement smt=null;
      ResultSet rst=null;

      while (true) {

      smt=con_cp.createStatement();
      rst=smt.executeQuery(sql);
      while(rst.next())
      {
      id=rst.getString("id");
      nNeedReport=rst.getByte("nNeedReport");
      nPriority=rst.getByte("nPriority");
      sServerId=rst.getString("sServerId");
      nMsgFormat=rst.getByte("nMsgFormat");
      sFeeType=rst.getString("sFeeType");
      sFeeCode=rst.getString("sFeeCode");
      sFixedFee=rst.getString("sFixedFee");
      sValidTime=rst.getString("sValidTime");
      sAtTime = rst.getString("sAtTime");
      sChargeTermId = rst.getString("sChargeTermId");
      sDestTermId = rst.getString("sDestTermId");
      sReplyPath = rst.getString("sReplyPath");
      nMsgLength = rst.getInt("nMsgLength");
       System.out.print("nMsgLength:"+nMsgLength);
      //cMsgCont=new byte[nMsgLength];
      cMsgCont=rst.getString(15);
      System.out.print("cMsgCont:"+cMsgCont);

      cMsgCont = rst.getString("cMsgCont");
      System.out.print("cMsgCont:"+cMsgCont);
      nMsgType = rst.getString("nMsgType");
      flag = rst.getString("flag");
      nsert_time = rst.getString("insert_time");
      sequenceid = rst.getInt("sequencid");

      //发送数据
      Statement smtdel=con_cp.createStatement();

        //PHSSubmit submit = new PHSSubmit(nNeedReport, nPriority, sServerId, sFeeType,  sFixedFee,sFeeCode, nMsgFormat,sChargeTermId, sChargeTermId, sDestTermId,cMsgCont);

        //System.out.print("submit:"+submit);
        phsClient.ServiceId=sServerId;
        phsClient.spNumber=sReplyPath;
        phsClient.feecode=sFeeCode;
        phsClient.feetype=sFeeType;
        phsClient.content=cMsgCont;
        //phsClient.squenceid=String.valueOf(sequenceid);

        phsClient.submit(sDestTermId);


      String sqldel="update phs_submit set handleflag='1' where id='"+id+"'";
      smtdel.executeUpdate(sqldel);
      }

      sleep(100);

      }
    }catch(Exception e)
    {
    e.printStackTrace();
    return;
    }finally {
    beanCP.setfreeconnection();
    }


  }
  public static void main(String[] args) {
    try{
      TestClient phsclient = new TestClient();
      PHSSubmtThread PHSSubmtThread1 = new PHSSubmtThread(phsclient);
      PHSSubmtThread1.start();
    }catch(Exception e)
    {}

  }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?