数据库连接池的研究与实现摘要在基于JDBC的数据库实际应用开发中,对数据库连接的管理是一个重点也是一个难点,频繁对数据库的连接与关闭操作、多客户对数据库的并发访问,一定程度上决定了WEB系统的响应以及应用性能。使用数据库连接池方式能对数据库的连接进行管理和维护,上层应用程序通过数据库连接池使用数据库资源能提升系统性能,充分利用系统资源。文章通过介绍、分析数据库连接池工作的基本原理,了解目前流行的WEB服务器在数据库连接池方面的使用现状后,总结一了些数据库连接池开发程序中容易忽略的问题。并在学习掌握了实现连接池的关键技术后给出了一个较为高效的连接池管理策略,在这种策略思想的指导下实际开发出一个数据库连接池模块,使得上层应用通过本连接池访问数据库资源变得相对高效和容易,从实际上论证了这种设计方案的可行性。关键词:连接池;数据库;JDBC;并发访问ResearchandrealizationoftheDatabaseConnectionPoolAbstractInthepracticallyapplicationdevelopmentofdatabasebasedonJDBC,themanagementofdatabaseconnectionisakeypointandalsoadifficulty.TheresponseandperformanceoftheWEBsystemaredependedonfrequentlyconnecting,closingandmulti-useraccessinginacertainextent.UsingtheDatabaseConnectionPoolcanprovidemanagementandmaintenanceforconnectionsofthedatabase.TheupperapplicationsmayaccessthedatabaserecourseviatheDatabaseConnectionPool,inordertoupgradesystemperformanceandfullyutilizethesystemrecourse.ThisarticlesummarizessomeissueswhichareeasilyignoredintheapplicationdevelopmentoftheDatabaseConnectionPoolbythewayofintroducingandanalyzingthebasalworkingprinciplesoftheDatabaseConnectionPool,comprehendingtheusingactualityoftheDatabaseConnectionPoolonthepopularWEBservers.Besides,IestablishedacomparativelyhighlyeffectivepolicyoftheConnectionPoolmanagementafterhavinglearnedandcomprehendedkeytechniqueofimplementingtheConnectivityPool,andactuallyhaddevelopedaDatabaseConnectionPoolmoduleundertheguidanceofthatpolicy,causingtheaccessofsystemresourcebytheupperapplicationsviacurrentConnectivityPoolbecomingrelativelyhighlyeffectiveandeasy,demonstratedthefeasibilityofthisdesignprojectinpractice.Keywords:DatabaseConnectionPool;Database;JDBC;Concurrenceaccess目录论文总页数:22页1引言..........................................................................................................................................11.1课题背景................................................................................................................................11.2连接池的主要作用................................................................................................................11.3目前流行的WEB服务器数据库连接池方面使用现状........................................................11.3.1DHCP介绍.......................................................................................................................21.3.2Poolman介绍.................................................................................................................21.3.3C3P0介绍.......................................................................................................................21.3.4其他连接池(自写连接池)........................................................................................22相关理论基础..........................................................................................................................32.1数据库概述............................................................................................................................32.2数据库连接池的基本原理.....................................................................................................32.3连接池中的关键技术............................................................................................................42.3.1连接池的分配与释放....................................................................................................42.3.2连接池的维护................................................................................................................53系统总体设计思想及方案......................................................................................................53.1连接池中的关键类设计.........................................................................................................63.2连接池中的管理机制............................................................................................................73.3实现一个连接池的其他问题..................................................................错误!未定义书签。3.3.1事务处理........................................................................................................................83.3.2封装................................................................................................................................93.3.3并发................................................................................................................................93.3.4连接池的关闭................................................................................................................94具体的设计流程和实现........................................................................................................104.1连接池的建立.......................................................................................................................104.2连接池的管理.......................................................................................................................124.3连接池的关闭.......................................................................................................................144.4连接池的测试....................................................................................................................