⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smqueue.java

📁 WAP PUSH后台源码,WAP PUSH后台源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                                   String fileName=smmsg.content+"_"+k;
                                   FileInputStream fis = new FileInputStream(fileName);
                                   while(fis.available() != 0) {
                                        j = fis.read();
                                        m_byte[i++] = (new Integer(j)).byteValue();
                                        if(i >= 140)	break;
                                   }
                                   fis.close();
                                   smmsg.contentMulti[k]=new String(m_byte);
                              }
                         }catch(Exception e){
                              System.out.println("读多个文本文件出错:"+e);
                         }
                         break;
                    case 6:
                         break;
                    case 7:
                         break;
                    case 8:
                         break;
                    case 9:
                         break;
               }
//               if (smmsg.submitMulti == 1) {
//                    stmtQuery = dbconn.createStatement();
//                    ResultSet rs1 =stmtQuery.executeQuery("select destinationAddr from tsmsmult where queueID=" +l);
//                    Vector vector = new Vector();
//                    while (rs1.next()){
//                         vector.addElement(rs1.getString("destinationAddr"));
//                    }
//                    rs1.close();
//                    stmtQuery.close();
//                    if (vector.size() > 0){
//                         smmsg.destAddr = new String[vector.size()];
//                    }
//                    for (int i = 0; i < vector.size(); i++){
//                         smmsg.destAddr[i] = vector.elementAt(i).toString();
//                    }
//               }
//               if (smmsg.submitMulti == 2) {
//                    try{
//                         int i=0,j=0;
//                         byte m_byte[] = new byte[140];
//                         String fileName=smmsg.content;
//                         FileInputStream fis = new FileInputStream(fileName);
//                         while(fis.available() != 0) {
//                              j = fis.read();
//                              m_byte[i++] = (new Integer(j)).byteValue();
//                              if(i >= 140)	break;
//                         }
//                         fis.close();
//                         smmsg.binaryContent=m_byte;
//                    }catch(Exception e){
//                         System.out.println("读二进制文件出错:"+e);
//                    }
//               }
               return smmsg;
          }
          catch (SQLException e) {
               System.out.println("取短信信息时读数据库出错:"+e);
               if ((dbconn != null) && autoCommit) {
                    try {
                         dbconn.rollback();
                         dbconn.setAutoCommit(autoCommit);
                    }
                    catch (SQLException ee) {
                         System.out.println("取短信信息时读数据库错误之后关连接出错:"+ee);
                    }
               }
               throw new SMQueueAccessException(e.toString());
          }
          finally {
               try {
                    if (stmtQuery != null) stmtQuery.close();
                    if (stmtUpdate != null) stmtUpdate.close();
               }
               catch (Exception qe) {
                    System.out.println("取短信信息时读数据库错误之后关连接出错:"+qe);
                    throw new SMQueueAccessException("Close Statement Error!");
               }
               finally {
                    stmtQuery = null;
                    stmtUpdate = null;
               }
          }

     }


     /**
      * 短消息发送函数,将多地址发送短消息保存到队列中
      * @param SMMsg SMMessage短消息对象
      * @return 返回值为短消息在队列中的ID,如果为0表示短消息未能保存到队列中,可能的原因是SMMessage对象中的值不正确
      * @exception SMParameterExceptionn 原因是SMMessage对象中的值不正确
      * @exception SMQueueAccessException 不能存取短消息队列,可能的原因是不能存取数据库
      */
     private synchronized boolean SMTransact(String[] sql)
               throws SMParameterException, SMQueueAccessException {

          if (sql == null)
               throw new SMParameterException("Null SQL error");
          if (dbconn == null)
               throw new SMQueueAccessException("Connetion unvailable!");

          boolean auto = false;

          Statement stmt = null;

          try {

               auto = dbconn.getAutoCommit();
               dbconn.setAutoCommit(false);

               stmt = dbconn.createStatement();

               for (int i = 0; i < sql.length; i++)
                    stmt.executeUpdate(sql[i]);
               stmt.close();

               if (auto) {
                    dbconn.commit();
                    dbconn.setAutoCommit(auto);
               }
               return true;

          }
          catch (SQLException e) {
               try {
                    if (auto) {
                         dbconn.rollback();
                         dbconn.setAutoCommit(auto);
                    }
               }
               catch (Exception err) {
                    throw new SMQueueAccessException("DB commit error");
               }
               return false;
          }
          finally {
               try {
                    if (stmt != null)
                         stmt.close();
               }
               catch (Exception qe) {
                    throw new SMQueueAccessException("Close Statement  error!");
               }
               finally {
                    stmt = null;
               }
          }
     }

     /**
      * Insert the method's description here.
      * Creation date: (2000-12-25 16:18:17)
      * @return int
      * @param sql java.lang.String
      */
     private synchronized int SMTransact(String sql)
               throws SMParameterException, SMQueueAccessException {

          if (sql == null)
               throw new SMParameterException("Null SQL error");
          if (dbconn == null)
               throw new SMQueueAccessException("Connetion unvailable!");

          Statement stmt = null;
          int retcode;

          try {

               stmt = dbconn.createStatement();
               retcode = stmt.executeUpdate(sql);

          }
          catch (SQLException e) {
               throw new SMQueueAccessException("DB commit error");
          }
          finally {
               try {
                    if (stmt != null)
                         stmt.close();
               }
               catch (Exception qe) {
                    throw new SMQueueAccessException("Close Statement  error!");
               }
               finally {
                    stmt = null;
               }
          }
          return retcode;
     }

     /**
      * 将队列中指定的短消息的发送标示改为SMMessage.NOT_IN_PROCESSING
      * Creation date: (2001-2-9 9:35:05)
      * @param msgID long
      * @exception SMQueueAccessException
      * @exception SMParameterException
      */
     public void reSendMessage(long queueID)
               throws SMQueueAccessException, SMParameterException {
          if (queueID <= 0) {
               throw new SMQueueAccessException("valid message ID");
          }

          String sql ="update tsmsqueu set sendStat=0 where queueID="+queueID;
          if (SMTransact(sql) <= 0) {
               throw new SMQueueAccessException("cannot update the sendstat of " + queueID);
          }

     }
     /**
      * 此方法删除队列中的短消息
      * Creation date: (2000-12-25 18:13:56)
      * @param id Long
      */
     public int remove(long queueID)
               throws SMQueueAccessException, SMParameterException {
          String sql ="delete from tsmsqueu where queueID="+queueID;
          return (SMTransact(sql));
     }
}

⌨️ 快捷键说明

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