本文整理汇总了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)
示例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)
示例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())