欢迎光临
我们一直在努力

一个连接池的例子(来自JIVE)(5)-JSP教程,数据库相关

建站超值云服务器,限时71元/月

//文件: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);
   
}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 一个连接池的例子(来自JIVE)(5)-JSP教程,数据库相关
分享到: 更多 (0)

相关推荐

  • 暂无文章