auctionshopcache.java

来自「源码/软件简介: 云网论坛1.1RC国际版是采用JSP开发的集论坛、CMS(网」· Java 代码 · 共 60 行

JAVA
60
字号
package com.redmoon.forum.plugin.auction;

import cn.js.fan.base.ObjectCache;
import cn.js.fan.db.Conn;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class AuctionShopCache extends ObjectCache {
    String prefix = "AuctionShopId_";

    public AuctionShopCache() {
        super();
    }

    public AuctionShopCache(AuctionShopDb auctionShopDb) {
        super(auctionShopDb);
    }

    public String getShopUserNameById(int id) {
        String userName = (String) rmCache.get(prefix + id);
        if (userName == null) {
            ResultSet rs = null;
            Conn conn = new Conn(connname);
            try {
                String sql = "select userName from " + objectDb.getTableName() +
                             " where id=?";
                PreparedStatement ps = conn.prepareStatement(sql);
                ps.setInt(1, id);
                rs = conn.executePreQuery();
                if (rs.next()) {
                    // shopName,address,tel,desciprtion,isValid,reason
                    userName = rs.getString(1);
                    try {
                        rmCache.put(prefix + id, userName);
                    } catch (Exception e) {
                        logger.error("getShopUserNameById1:" + e.getMessage());
                    }
                }
            } catch (SQLException e) {
                logger.error("getShopUserNameById2:" + e.getMessage());
            } finally {
                if (conn != null) {
                    conn.close();
                    conn = null;
                }
            }
        }
        return userName;
    }

    public void setGroup() {
        group = "AUCTIONSHOP";
    }

    public void setGroupCount() {
        COUNT_GROUP_NAME = "AUCTIONSHOPCOUNT";
    }
}

⌨️ 快捷键说明

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