简体   繁体   English

C3p0连接池Tomcat Apache概念

[英]C3p0 connection pooling Tomcat Apache concept

1) Difference between the constructors of InitialContext. 1)InitialContext的构造函数之间的差异。

public InitialContext(Hashtable<?,?> environment)

what does this constructor do and what will environment parameter do . 此构造函数的作用和环境参数的作用。

2) 2)

    Hashtable<Object, String> environment= new Hashtable<Object, String> (2);
     --
     --   
    Context ctx = new InitialContext( environment);
    ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();
    comboPooledDataSource.setJdbcUrl(----);
    comboPooledDataSource.setDriverClass(----);
    ctx.bind (__);

please explain each line what does it do.. 请解释每一行的作用。

3)Why to create combopooldatasource object ,instead we can create datasource object..?? 3)为什么要创建combopooldatasource对象,而不能创建datasource对象呢?

Answer for 3rd question : Datasource can not be created for ordinary domains,its only for JNDI domains. 第三个问题的答案:不能为普通域创建数据源,只能为JNDI域创建数据源。

For 1st : InitialContext is used to set the environment to create the pooled datasource by creating .bindings file 对于1st:InitialContext用于设置环境以通过创建.bindings文件来创建池化数据源。

For 2nd : Context sets the environment. 对于2nd:上下文设置环境。 ComboPooledDataSource object is created. 创建ComboPooledDataSource对象。 For that object the url and jdbc driver class wll be set to take the connections from DB to the Pool. 对于该对象,将设置url和jdbc驱动程序类以采用从DB到Pool的连接。 Above set things will be binded to the context and it will be wriiten in .bindings file in encoded format 上面设置的内容将绑定到上下文,并将以编码格式在.bindings文件中写入

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM