📄 mtdao.java
字号:
package com.gctech.sms.dao;
import com.gctech.sms.msg.MTInfo;
import java.sql.Connection;
import java.sql.PreparedStatement;
import com.gctech.sms.util.ConnectionManager;
import org.apache.log4j.Logger;
import com.gctech.sms.core.MTStatus;
import org.apache.commons.lang.RandomStringUtils;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: gctech</p>
* @author 王红宝
* @version $Id: MTDao.java,v 1.2 2004/04/22 01:25:15 wanghb Exp $
*/
public class MTDao {
public MTDao() {
}
static final String INSERT_MTSUC = "insert into MTSUC(MsgId,MsgId2,Gateway,ProductId,SubType,Content,SrcTerm,"
+"FeeMobile,NeedReply,MsgLevel,ServiceId,MsgFormat,FeeType,FeeCode,FeeUserType,"
+"AtTime,ValidTime,DestMobile,Status,spmsgid)values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
static final String INSERT_MTFAL = "insert into MTFAL(MsgId,MsgId2,Gateway,ProductId,SubType,Content,SrcTerm,"
+"FeeMobile,NeedReply,MsgLevel,ServiceId,MsgFormat,FeeType,FeeCode,FeeUserType,"
+"AtTime,ValidTime,DestMobile,Status,spmsgid)values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
public static int updateMt(String msgId2, int status){
int rt = -1;
Connection con = null;
PreparedStatement pstmt = null;
try{
con = ConnectionManager.getInstance().getConnection(MTDao.class);
pstmt = con.prepareStatement("update mtsuc set status="+status +" where msgid2=?");
pstmt.setString(1, msgId2);
rt = pstmt.executeUpdate();
}catch( Throwable e ){
logger.error(e, e);
}finally{
if ( pstmt != null ){
try {
pstmt.close();
}
catch (Throwable ex) {
logger.error(ex, ex);
}
}
if ( con != null ){
try {
con.close();
}
catch (Throwable ex) {
logger.error(ex, ex);
}
}
return rt;
}
}
static int add(MTInfo mt, int table){
int rt = -1;
Connection con = null;
PreparedStatement pstmt = null;
try{
con = ConnectionManager.getInstance().getConnection(MTDao.class);
if ( table == 0 )
pstmt = con.prepareStatement(INSERT_MTSUC);
else
pstmt = con.prepareStatement(INSERT_MTFAL);
logger.debug(""+mt.MsgID2.length());
//pstmt.setString(1, mt.MsgID2);
int n = 1;
pstmt.setString(n++, mt.MsgID);
pstmt.setString(n++, mt.MsgID2);
pstmt.setInt(n++, mt.gateway);
pstmt.setString(n++, mt.productID); pstmt.setInt(n++, mt.bSubType);
pstmt.setString(n++, mt.content); pstmt.setString(n++, mt.srcPhone);
pstmt.setString(n++, mt.FeeterminalId); pstmt.setInt(n++, mt.bNeedReply);
pstmt.setInt(n++, mt.bMsgLevel); pstmt.setString(n++, mt.ServiceID);
pstmt.setInt(n++, mt.bMsgFmt); pstmt.setString(n++, mt.FeeType);
pstmt.setString(n++, mt.FeeCode); pstmt.setInt(n++, mt.bFeeUserType);
pstmt.setString(n++, mt.AtTime); pstmt.setString(n++, mt.ValidTime);
logger.debug(""+mt.sDestPhone.length());
pstmt.setString(n++, mt.sDestPhone);
pstmt.setInt(n++, mt.nStatus);
pstmt.setString(n++, mt.spMsgId);
pstmt.execute();
}catch( Throwable e ){
logger.error(e, e);
//写到文件中
}finally{
if ( pstmt != null ){
try {
pstmt.close();
}
catch (Throwable ex) {
logger.error(ex, ex);
}
}
if ( con != null ){
try {
con.close();
}
catch (Throwable ex) {
logger.error(ex, ex);
}
}
return rt;
}
}
public static int addSuc(MTInfo mt){
return add(mt, 0);
}
public static int addFal(MTInfo mt){
return add(mt, 1);
}
static final Logger logger = Logger.getLogger(MTDao.class);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -