Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Legacy JDBC Driver

It’s common to inherit a bit of code written with neither DataSources nor connection pooling of any sort in mind at all. For a variety of reasons, it may not be feasible to change your existing program logic (beyond editing the JDBC connection strings). Fortunately, DBCP supports the notion of a PoolingDriver—an implementation of a JDBC driver that implements a connection pool behind the scenes. As long as your application code opens and closes connections properly, you can add connection pooling at any time.

Listing 6-4 shows how a bit of legacy code can be adapted to support a connection pool. As you can see, you will still need to add a bit of code to initialize the connection pool (as shown in the registerPoolingDriver() method) to your legacy application’s initialization process.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint