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

📄 splogininfodao.java

📁 采用JAVA开发
💻 JAVA
字号:
package com.gctech.sms.dao;


import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import com.gctech.sms.util.ConnectionManager;
import org.apache.log4j.Logger;
import java.sql.PreparedStatement;
import com.gctech.sms.vo.SpLoginInfo;

/**
 * <p>Title: SpLoginInfo数据访问类。</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: gctech</p>
 * @author 王红宝
 * @version $Id: SpLoginInfoDao.java,v 1.2 2004/04/22 01:25:16 wanghb Exp $
 */

public class SpLoginInfoDao {
  public SpLoginInfoDao() {
  }

  public static int add(SpLoginInfo info){
    int rt = -1;
    Connection con = null;
    PreparedStatement pstmt = null;
    try{
      con = ConnectionManager.getInstance().getConnection(SpLoginInfoDao.class);
      pstmt = con.prepareStatement("insert into spLoginInfo(spId,sharedSecret,clientIp)values(?,?,?)");
      pstmt.setString(1, info.getSpId());
      pstmt.setString(2, info.getSharedSecret());
      pstmt.setString(3, info.getClientIp());
      pstmt.execute();
      rt = 0;
    }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 SpLoginInfo findByPk(String spId){
    SpLoginInfo info = null;
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    try{
      con = ConnectionManager.getInstance().getConnection(SpLoginInfoDao.class);
      stmt = con.createStatement();
      rs = stmt.executeQuery("select * from spLoginInfo where spId='"+spId+"'");
      if ( rs.next() ){
        info = new SpLoginInfo();
        info.setClientIp(rs.getString("CLIENTIP"));
        info.setSharedSecret(rs.getString("SHAREDSECRET"));
        info.setSpId(rs.getString("SPID"));
      }
    }catch( Throwable e ){
      logger.error(e, e);
    }finally{
      if ( rs != null ){
        try {
          rs.close();
        }
        catch (Throwable ex) {
          logger.error(ex, ex);
        }
      }
      if ( stmt != null ){
        try {
          stmt.close();
        }
        catch (Throwable ex) {
          logger.error(ex, ex);
        }
      }
      if ( con != null ){
        try {
          con.close();
        }
        catch (Throwable ex) {
          logger.error(ex, ex);
        }
      }
    }

    return info;
  }

  static final Logger logger = Logger.getLogger(SpLoginInfoDao.class);
}

⌨️ 快捷键说明

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