📄 ipstoredb.java
字号:
package com.redmoon.forum.util;import cn.js.fan.db.*;import com.cloudwebsoft.framework.base.*;import com.cloudwebsoft.framework.db.*;import com.cloudwebsoft.framework.util.*;import cn.js.fan.util.StrUtil;public class IPStoreDb extends QObjectDb { public IPStoreDb() { } public IPStoreDb getIPStoreDb(long ip1, long ip2) { PrimaryKey pk = (PrimaryKey)primaryKey.clone(); pk.setKeyValue("ip1", new Long(ip1)); pk.setKeyValue("ip2", new Long(ip2)); return (IPStoreDb)getQObjectDb(pk.getKeys()); } public String getPosition(String ip) { try { long ipNum = IPUtil.ip2long(ip); String sql = "select ip1, ip2 from " + table.getName() + " where ip1<=? and ip2>=?"; JdbcTemplate jt = new JdbcTemplate(); ResultIterator ri = jt.executeQuery(sql, new Object[] {new Long(ipNum), new Long(ipNum)}); if (ri.hasNext()) { ResultRecord rr = (ResultRecord) ri.next(); IPStoreDb ipsd = getIPStoreDb(rr.getLong(1), rr.getLong(2)); return ipsd.getString("country"); } } catch (Exception e) { LogUtil.getLog(getClass()).error("getPosition:" + e.getMessage() + " " + StrUtil.trace(e)); } return ""; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -