亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? idbroker.java

?? 另外一種持久性o/m軟件
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
package org.apache.torque.oid;/* * Copyright 2001-2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License") * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */import java.math.BigDecimal;import java.sql.Connection;import java.sql.ResultSet;import java.sql.Statement;import java.util.ArrayList;import java.util.Hashtable;import java.util.Iterator;import java.util.List;import org.apache.commons.configuration.Configuration;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.apache.torque.Torque;import org.apache.torque.TorqueException;import org.apache.torque.map.DatabaseMap;import org.apache.torque.map.TableMap;import org.apache.torque.util.Transaction;//!!// NOTE:// It would be nice to decouple this from// Torque. This is a great stand-alone utility./** * This method of ID generation is used to ensure that code is * more database independent.  For example, MySQL has an auto-increment * feature while Oracle uses sequences.  It caches several ids to * avoid needing a Connection for every request. * * This class uses the table ID_TABLE defined in * conf/master/id-table-schema.xml.  The columns in ID_TABLE are used as * follows:<br> * * ID_TABLE_ID - The PK for this row (any unique int).<br> * TABLE_NAME - The name of the table you want ids for.<br> * NEXT_ID - The next id returned by IDBroker when it queries the *           database (not when it returns an id from memory).<br> * QUANTITY - The number of ids that IDBroker will cache in memory.<br> * <p> * Use this class like this: * <pre> * int id = dbMap.getIDBroker().getNextIdAsInt(null, "TABLE_NAME"); *  - or - * BigDecimal[] ids = ((IDBroker)dbMap.getIDBroker()) *     .getNextIds("TABLE_NAME", numOfIdsToReturn); * </pre> * * NOTE: When the ID_TABLE must be updated we must ensure that * IDBroker objects running in different JVMs do not overwrite each * other.  This is accomplished using using the transactional support * occuring in some databases.  Using this class with a database that * does not support transactions should be limited to a single JVM. * * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a> * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a> * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a> * @version $Id: IDBroker.java,v 1.31 2005/05/22 10:57:51 tfischer Exp $ */public class IDBroker implements Runnable, IdGenerator{    /** Name of the ID_TABLE = ID_TABLE */    public static final String ID_TABLE = "ID_TABLE";    /** Table_Name column name */    public static final String COL_TABLE_NAME = "TABLE_NAME";    /** Fully qualified Table_Name column name */    public static final String TABLE_NAME = ID_TABLE + "." + COL_TABLE_NAME;    /** ID column name */    public static final String COL_TABLE_ID = "ID_TABLE_ID";    /** Fully qualified ID column name */    public static final String TABLE_ID = ID_TABLE + "." + COL_TABLE_ID;    /** Next_ID column name */    public static final String COL_NEXT_ID = "NEXT_ID";    /** Fully qualified Next_ID column name */    public static final String NEXT_ID = ID_TABLE + "." + COL_NEXT_ID;    /** Quantity column name */    public static final String COL_QUANTITY = "QUANTITY";    /** Fully qualified Quantity column name */    public static final String QUANTITY = ID_TABLE + "." + COL_QUANTITY;    /** The TableMap referencing the ID_TABLE for this IDBroker. */    private TableMap tableMap;    /**     * The default size of the per-table meta data <code>Hashtable</code>     * objects.     */    private static final int DEFAULT_SIZE = 40;    /**     * The cached IDs for each table.     *     * Key: String table name.     * Value: List of Integer IDs.     */    private Hashtable ids = new Hashtable(DEFAULT_SIZE);    /**     * The quantity of ids to grab for each table.     *     * Key: String table name.     * Value: Integer quantity.     */    private Hashtable quantityStore = new Hashtable(DEFAULT_SIZE);    /**     * The last time this IDBroker queried the database for ids.     *     * Key: String table name.     * Value: Date of last id request.     */    private Hashtable lastQueryTime = new Hashtable(DEFAULT_SIZE);    /**     * Amount of time for the thread to sleep     */    private static final int SLEEP_PERIOD = 1 * 60000;    /**     * The safety Margin     */    private static final float SAFETY_MARGIN = 1.2f;    /**     * The houseKeeperThread thread     */    private Thread houseKeeperThread = null;    /**     * Are transactions supported?     */    private boolean transactionsSupported = false;    /**     * The value of ONE!     */    private static final BigDecimal ONE = new BigDecimal("1");    /** the configuration */    private Configuration configuration;    /** property name */    private static final String DB_IDBROKER_CLEVERQUANTITY =        "idbroker.clever.quantity";    /** property name */    private static final String DB_IDBROKER_PREFETCH =        "idbroker.prefetch";    /** property name */    private static final String DB_IDBROKER_USENEWCONNECTION =        "idbroker.usenewconnection";    /** the log */    private Log log = LogFactory.getLog(IDBroker.class);    /**     * Creates an IDBroker for the ID table.     *     * @param tMap A TableMap.     */    public IDBroker(TableMap tMap)    {        this.tableMap = tMap;        configuration = Torque.getConfiguration();        // Start the housekeeper thread only if prefetch has not been disabled        if (configuration.getBoolean(DB_IDBROKER_PREFETCH, true))        {            houseKeeperThread = new Thread(this);            // Indicate that this is a system thread. JVM will quit only when            // there are no more active user threads. Settings threads spawned            // internally by Torque as daemons allows commandline applications            // using Torque terminate in an orderly manner.            houseKeeperThread.setDaemon(true);            houseKeeperThread.setName("Torque - ID Broker thread");            houseKeeperThread.start();        }        // Check for Transaction support.  Give warning message if        // IDBroker is being used with a database that does not        // support transactions.        String dbName = tMap.getDatabaseMap().getName();        Connection dbCon = null;        try        {            dbCon = Torque.getConnection(dbName);            transactionsSupported = dbCon.getMetaData().supportsTransactions();        }        catch (Exception e)        {            transactionsSupported = false;        }        finally        {            try            {                // Return the connection to the pool.                dbCon.close();            }            catch (Exception e)            {            }        }        if (!transactionsSupported)        {            log.warn("IDBroker is being used with db '" + dbName                    + "', which does not support transactions. IDBroker "                    + "attempts to use transactions to limit the possibility "                    + "of duplicate key generation.  Without transactions, "                    + "duplicate key generation is possible if multiple JVMs "                    + "are used or other means are used to write to the "                    + "database.");        }    }    /**     * Set the configuration     *     * @param configuration the configuration     */    public void setConfiguration(Configuration configuration)    {        this.configuration = configuration;    }    /**     * Returns an id as a primitive int.  Note this method does not     * require a Connection, it just implements the KeyGenerator     * interface.  if a Connection is needed one will be requested.     * To force the use of the passed in connection set the configuration     * property torque.idbroker.usenewconnection = false     *     * @param connection A Connection.     * @param tableName an Object that contains additional info.     * @return An int with the value for the id.     * @exception Exception Database error.     */    public int getIdAsInt(Connection connection, Object tableName)        throws Exception    {        return getIdAsBigDecimal(connection, tableName).intValue();    }    /**     * Returns an id as a primitive long. Note this method does not     * require a Connection, it just implements the KeyGenerator     * interface.  if a Connection is needed one will be requested.     * To force the use of the passed in connection set the configuration     * property torque.idbroker.usenewconnection = false     *     * @param connection A Connection.     * @param tableName a String that identifies a table.     * @return A long with the value for the id.     * @exception Exception Database error.     */    public long getIdAsLong(Connection connection, Object tableName)        throws Exception    {        return getIdAsBigDecimal(connection, tableName).longValue();    }    /**     * Returns an id as a BigDecimal. Note this method does not     * require a Connection, it just implements the KeyGenerator     * interface.  if a Connection is needed one will be requested.     * To force the use of the passed in connection set the configuration     * property torque.idbroker.usenewconnection = false     *     * @param connection A Connection.     * @param tableName a String that identifies a table..     * @return A BigDecimal id.     * @exception Exception Database error.     */    public BigDecimal getIdAsBigDecimal(Connection connection,                                        Object tableName)        throws Exception    {        BigDecimal[] id = getNextIds((String) tableName, 1, connection);        return id[0];    }    /**     * Returns an id as a String. Note this method does not     * require a Connection, it just implements the KeyGenerator     * interface.  if a Connection is needed one will be requested.     * To force the use of the passed in connection set the configuration     * property torque.idbroker.usenewconnection = false     *     * @param connection A Connection should be null.     * @param tableName a String that identifies a table.     * @return A String id     * @exception Exception Database error.     */    public String getIdAsString(Connection connection, Object tableName)        throws Exception    {        return getIdAsBigDecimal(connection, tableName).toString();    }    /**     * A flag to determine the timing of the id generation     *     * @return a <code>boolean</code> value     */    public boolean isPriorToInsert()    {        return true;    }    /**     * A flag to determine the timing of the id generation     *     * @return a <code>boolean</code> value     */    public boolean isPostInsert()    {        return false;    }    /**     * A flag to determine whether a Connection is required to     * generate an id.     *     * @return a <code>boolean</code> value     */    public boolean isConnectionRequired()    {        return false;    }    /**     * This method returns x number of ids for the given table.     *     * @param tableName The name of the table for which we want an id.     * @param numOfIdsToReturn The desired number of ids.     * @return A BigDecimal.     * @exception Exception Database error.     */    public synchronized BigDecimal[] getNextIds(String tableName,                                                int numOfIdsToReturn)        throws Exception    {        return getNextIds(tableName, numOfIdsToReturn, null);    }    /**     * This method returns x number of ids for the given table.     * Note this method does not require a Connection.     * If a Connection is needed one will be requested.     * To force the use of the passed in connection set the configuration     * property torque.idbroker.usenewconnection = false     *     * @param tableName The name of the table for which we want an id.     * @param numOfIdsToReturn The desired number of ids.     * @param connection A Connection.     * @return A BigDecimal.     * @exception Exception Database error.     */    public synchronized BigDecimal[] getNextIds(String tableName,                                                int numOfIdsToReturn,                                                Connection connection)        throws Exception    {        if (tableName == null)        {            throw new Exception("getNextIds(): tableName == null");        }        // A note about the synchronization:  I (jmcnally) looked at        // the synchronized blocks to avoid thread issues that were        // being used in this and the storeId method.  I do not think        // they were being effective, so I synchronized the method.        // I have left the blocks that did exist commented in the code        // to make it easier for others to take a look, because it        // would be preferrable to avoid the synchronization on the        // method        List availableIds = (List) ids.get(tableName);        if (availableIds == null || availableIds.size() < numOfIdsToReturn)        {            if (availableIds == null)            {                log.debug("Forced id retrieval - no available list");            }            else            {                log.debug("Forced id retrieval - " + availableIds.size());            }            storeIDs(tableName, true, connection);            availableIds = (List) ids.get(tableName);        }        int size = availableIds.size() < numOfIdsToReturn                ? availableIds.size() : numOfIdsToReturn;        BigDecimal[] results = new BigDecimal[size];        // We assume that availableIds will always come from the ids        // Hashtable and would therefore always be the same object for        // a specific table.        //        synchronized (availableIds)        //        {        for (int i = size - 1; i >= 0; i--)        {            results[i] = (BigDecimal) availableIds.get(i);            availableIds.remove(i);        }        //        }        return results;    }    /**     * Describe <code>exists</code> method here.     *     * @param tableName a <code>String</code> value that is used to identify     * the row     * @return a <code>boolean</code> value     * @exception TorqueException if an error occurs     * @exception Exception a generic exception.     */    public boolean exists(String tableName)        throws TorqueException, Exception    {        String query = new StringBuffer(100)            .append("select ")            .append(TABLE_NAME)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91在线精品秘密一区二区| 成人激情黄色小说| 亚洲一区二区四区蜜桃| 香蕉加勒比综合久久| 亚洲欧美日韩在线播放| 亚洲欧美成人一区二区三区| 亚洲免费看黄网站| 亚洲黄色免费网站| 日韩精品欧美精品| 免费精品视频在线| 久草在线在线精品观看| 国产精品影音先锋| 懂色av中文一区二区三区| av亚洲产国偷v产偷v自拍| 91福利精品第一导航| 欧美三级电影一区| 日韩一区二区三| 国产亚洲精品免费| 亚洲日本在线观看| 日韩精品午夜视频| 国产成人免费视频一区| www.激情成人| 欧美三级在线视频| 欧美成人精品高清在线播放| 国产日韩欧美亚洲| 一区二区三区鲁丝不卡| 奇米综合一区二区三区精品视频| 精品无码三级在线观看视频| 精品国产一区久久| 国产精品麻豆一区二区| 亚洲午夜电影在线| 国产毛片一区二区| 色av一区二区| 国产亚洲一本大道中文在线| 一级女性全黄久久生活片免费| 日韩精品福利网| 93久久精品日日躁夜夜躁欧美| 欧美日韩亚洲高清一区二区| www国产亚洲精品久久麻豆| 亚洲欧美日韩国产另类专区| 九色综合国产一区二区三区| 欧洲视频一区二区| 久久精品一区四区| 日韩电影免费在线看| 岛国精品在线观看| 日韩欧美国产一二三区| 亚洲免费av观看| 国产激情视频一区二区在线观看| 欧美日韩mp4| 亚洲男人天堂av| 国产精品自在欧美一区| 欧美日本在线观看| 一卡二卡欧美日韩| 不卡影院免费观看| 久久蜜桃av一区二区天堂| 视频一区二区三区入口| 91丝袜呻吟高潮美腿白嫩在线观看| 日韩精品一区二区三区在线播放| 亚洲主播在线播放| 91免费在线视频观看| 国产欧美视频一区二区| 久久精品国产澳门| 欧美一区三区二区| 亚洲午夜久久久久久久久电影院 | 激情综合色综合久久| 一本久久精品一区二区| 国产香蕉久久精品综合网| 蜜臀久久99精品久久久久宅男| 欧美专区亚洲专区| 亚洲午夜一区二区三区| 在线区一区二视频| 亚洲蜜桃精久久久久久久| 北条麻妃一区二区三区| 欧美国产成人精品| 国产91丝袜在线播放0| 国产亚洲成aⅴ人片在线观看| 另类的小说在线视频另类成人小视频在线| 欧美精品国产精品| 男人的天堂亚洲一区| 精品理论电影在线| 国产美女精品人人做人人爽| 国产日韩一级二级三级| 国产成人亚洲综合a∨婷婷 | 亚洲人成人一区二区在线观看| 国产精品小仙女| 国产精品免费丝袜| 91色在线porny| 亚洲无线码一区二区三区| 制服丝袜激情欧洲亚洲| 国产一区二区视频在线播放| 欧美国产日产图区| 色av一区二区| 日韩av成人高清| 久久午夜免费电影| 不卡av在线网| 日韩精品一二三四| 久久久亚洲高清| 91免费在线播放| 美女一区二区三区| 中文一区在线播放| 日本乱人伦aⅴ精品| 免费观看一级欧美片| 欧美激情一区二区三区| 欧美亚洲国产一区二区三区va| 青草国产精品久久久久久| 久久老女人爱爱| 在线观看av一区| 国内精品久久久久影院色| 日韩一区欧美小说| 91精品视频网| 成人app在线观看| 久久国产欧美日韩精品| 亚洲精品你懂的| 久久先锋影音av鲁色资源网| 99久久免费视频.com| 蜜臀久久久99精品久久久久久| 国产精品久久久久久久午夜片| 欧美精品在线一区二区三区| 成人免费黄色在线| 轻轻草成人在线| 尤物视频一区二区| 久久久精品免费网站| 欧美日韩一级二级| 国产成人av福利| 久草中文综合在线| 午夜精品久久久久久| 亚洲国产电影在线观看| 欧美一级专区免费大片| av日韩在线网站| 国产精品123| 国产在线精品免费| 免费久久精品视频| 亚洲成人精品影院| 自拍偷拍欧美激情| 欧美高清在线一区二区| 日韩免费高清电影| 欧美巨大另类极品videosbest | 最新国产の精品合集bt伙计| 欧美成人在线直播| 欧美精品久久99久久在免费线 | 专区另类欧美日韩| 久久精品一区二区三区不卡牛牛| 91精品国产综合久久小美女| 欧美午夜精品久久久久久超碰| 成人教育av在线| 国产一区二区三区av电影| 日韩精品一二三四| 日韩精品91亚洲二区在线观看| 亚洲国产精品一区二区www| 亚洲男同性恋视频| 一区二区三区在线观看欧美 | 在线亚洲+欧美+日本专区| 成人av资源网站| 成人性生交大片免费看在线播放| 国产一区二区三区香蕉| 久久99精品国产麻豆不卡| 日韩国产在线观看| 免费的国产精品| 奇米色777欧美一区二区| 免费在线观看视频一区| 美女视频免费一区| 久久精品国产精品亚洲红杏| 久久精品国内一区二区三区| 蜜臀va亚洲va欧美va天堂| 狠狠色综合日日| 国产99久久久国产精品| 成人黄色在线网站| 色综合色综合色综合色综合色综合| 色视频欧美一区二区三区| 在线观看日韩电影| 欧美精品一卡二卡| 欧美电视剧免费全集观看| 国产婷婷色一区二区三区| 国产精品国产精品国产专区不蜜| 一区二区三区在线看| 日本 国产 欧美色综合| 国产麻豆精品视频| 99精品视频一区| 欧美理论片在线| 欧美激情中文字幕| 亚洲一区二区精品3399| 精品一区二区三区在线播放| 丁香天五香天堂综合| 日本精品一级二级| 精品国产乱码久久久久久蜜臀 | 性欧美疯狂xxxxbbbb| 国产资源在线一区| 色噜噜狠狠色综合欧洲selulu| 欧美一区二区在线免费播放| 国产日韩视频一区二区三区| 亚洲一区二区视频在线观看| 精品一区精品二区高清| 一本色道久久综合亚洲aⅴ蜜桃 | 国产精品一区二区在线看| 99国产精品视频免费观看| 91精品久久久久久久99蜜桃 | 久久婷婷一区二区三区| 亚洲精品成人精品456| 国产在线国偷精品免费看| 欧美色精品天天在线观看视频|