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

📄 一个连接池的例子(来自jive)(5).txt

📁 java技术综合: 总结多家java技术论坛中的常见问题
💻 TXT
字号:
作者:sonymusic
email: sonymusic@china.com
日期:2001-5-17 11:36:03
//文件:DbConnectionProvider.java

package com.qingtuo.db.pool;

import java.sql.*;
import java.util.*;

public abstract class DbConnectionProvider {

	/** Dummy values. Override in subclasses. **/
	private static final String NAME = "";
	private static final String DESCRIPTION = "";
	private static final String AUTHOR = "";
	private static final int MAJOR_VERSION = 0;
	private static final int MINOR_VERSION = 0;
	private static final boolean POOLED = false;

	/**
	 * Returns the name of the connection provider.
	 */
	public String getName() {
		return NAME;
	}

	/**
	 * Returns a description of the connection provider.
	 */
	public String getDescription() {
		return DESCRIPTION;
	}

	/**
	 * Returns the author of the connection provider.
	 */
	public String getAuthor() {
		return AUTHOR;
	}

	/**
	 * Returns the major version of the connection provider, i.e. the 1 in 1.0.
	 */
	public int getMajorVersion() {
		return MAJOR_VERSION;
	}

	public int getMinorVersion() {

		return MINOR_VERSION;

	}

	/**
	 * Returns true if this connection provider provides connections out
	 * of a connection pool.
	 */
	public boolean isPooled() {
		return POOLED;
	}

	/**
	 * Returns a database connection. When a Jive component is done with a
	 * connection, it will call the close method of that connection. Therefore,
	 * connection pools with special release methods are not directly
	 * supported by the connection provider infrastructure. Instead, connections
	 * from those pools should be wrapped such that calling the close method
	 * on the wrapper class will release the connection from the pool.
	 */
	public abstract Connection getConnection();

	/**
	 * Starts the connection provider. For some connection providers, this
	 * will be a no-op. However, connection provider users should always call
	 * this method to make sure the connection provider is started.
	 */
	protected abstract void start();

	/**
	 * This method should be called whenever properties have been changed so
	 * that the changes will take effect.
	 */
	protected abstract void restart();

	/**
	 * Tells the connection provider to destroy itself. For many connection
	 * providers, this will essentially result in a no-op. However,
	 * connection provider users should always call this method when changing
	 * from one connection provider to another to ensure that there are no
	 * dangling database connections.
	 */
	protected abstract void destroy();

	/**
	 * Returns the value of a property of the connection provider.
	 *
	 * @param name the name of the property.
	 * @returns the value of the property.
	 */
	public abstract String getProperty(String name);

	/**
	 * Returns the description of a property of the connection provider.
	 *
	 * @param name the name of the property.
	 * @return the description of the property.
	 */
	public abstract String getPropertyDescription(String name);

	/**
	 * Returns an enumeration of the property names for the connection provider.
	 */
	public abstract Enumeration propertyNames();

	/**
	 * Sets a property of the connection provider. Each provider has a set number
	 * of properties that are determined by the author. Trying to set a non-
	 * existant property will result in an IllegalArgumentException. 
	 *
	 * @param name the name of the property to set.
	 * @param value the new value for the property.
	 */
	public abstract void setProperty(String name, String value);
   
}

⌨️ 快捷键说明

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