当前位置: 首页>>代码示例>>Python>>正文


Python DriverManager.getDriver方法代码示例

本文整理汇总了Python中java.sql.DriverManager.getDriver方法的典型用法代码示例。如果您正苦于以下问题:Python DriverManager.getDriver方法的具体用法?Python DriverManager.getDriver怎么用?Python DriverManager.getDriver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.DriverManager的用法示例。


在下文中一共展示了DriverManager.getDriver方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from java.sql import DriverManager [as 别名]
# 或者: from java.sql.DriverManager import getDriver [as 别名]
    def __init__(self, connectURI, username, password, pool_name):
        self.connectionPool = GenericObjectPool(None)
        self._pool_name = pool_name

        source = BasicDataSource()
        source.setUrl(connectURI)
        source.setUsername(username)
        source.setPassword(password)
        source.setInitialSize(1) # Number of connections to start with
        source.setMinIdle(5)     # Allow a bottom of 5 idle connections
        source.setMaxActive(10)  # Max of 10 database connection
        source.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED)
        source.setMinEvictableIdleTimeMillis(500) 

        self.connectionFactory = DataSourceConnectionFactory(source)

        #  Now we'll create the PoolableConnectionFactory, which wraps
        #  the "real" Connections created by the ConnectionFactory with
        #  the classes that implement the pooling functionality.
        self.poolableConnectionFactory = PoolableConnectionFactory(self.connectionFactory,
                self.connectionPool,
                None,
                None,
                False,
                True)

        #  Finally, we create the PoolingDriver itself...
        Class.forName("org.apache.commons.dbcp.PoolingDriver")
        driver = DriverManager.getDriver("jdbc:apache:commons:dbcp:")

        #  ...and register our pool with it.
        driver.registerPool(self._pool_name, self.connectionPool)
开发者ID:VanyaDNDZ,项目名称:doj-sybase,代码行数:34,代码来源:pool.py

示例2: shutdownDriver

# 需要导入模块: from java.sql import DriverManager [as 别名]
# 或者: from java.sql.DriverManager import getDriver [as 别名]
 def shutdownDriver(self):
     driver = DriverManager.getDriver("jdbc:apache:commons:dbcp:")
     driver.closePool(self._pool_name)
开发者ID:VanyaDNDZ,项目名称:doj-sybase,代码行数:5,代码来源:pool.py

示例3: printDriverStats

# 需要导入模块: from java.sql import DriverManager [as 别名]
# 或者: from java.sql.DriverManager import getDriver [as 别名]
 def printDriverStats(self):
     driver = DriverManager.getDriver("jdbc:apache:commons:dbcp:")
     connectionPool = driver.getConnectionPool(self._pool_name)
     print "NumActive: " + str(connectionPool.getNumActive())
     print "NumIdle: " + str(connectionPool.getNumIdle())
开发者ID:VanyaDNDZ,项目名称:doj-sybase,代码行数:7,代码来源:pool.py


注:本文中的java.sql.DriverManager.getDriver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。