Results 1 to 2 of 2

Thread: Bind a specific existing Connection instance?

  1. #1
    Join Date
    Aug 2004
    Location
    Tampa, FL
    Posts
    39

    Default Bind a specific existing Connection instance?

    Assuming I am using all of Spring framework's convenience classes to do data access using both JDBC and Hibernate, I want to use an existing Connection instance for all data access. I don't want this Connection to close until being told to close either explicitly or by timeout. Any ideas how something like this could be done?

    My guess from studying the source code would be to do something like this:

    Code:
    TransactionSynchronizationManager.bindResource(dataSource, connection);
    The reason I want to do this is we have an Oracle database that has stored procedures that produce temp tables and we want these temp tables to remain active between requests to reduce the cost of having to reload them for every request. The user interaction will be done through web services. So we're planning on holding the Connection instance in HttpSession for a particular user and reuse the same instance of it for every web service call that the user does, until they timeout or call a logout method. I understand there are a number of potential problems with this design, but we want to compare this with having to reload the temp tables on each request and maybe provide both options.

    I also may look at doing something with the DataSource, maybe extend DriverManagerDataSource and have it check a ThreadLocal to see if a Connection instance already exists and return that instead for getConnection().

  2. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default Custom DataSource

    I would recommend implementing the Spring SmartDataSource interface, which extends javax.sql.DataSource. This enables it to control whether the Spring JDBC framework closes connections.

Similar Threads

  1. Replies: 4
    Last Post: Oct 5th, 2005, 11:04 AM
  2. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  3. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  4. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM
  5. DefaultAdvisorAutoProxyCreator skipping beans
    By youngm in forum Container
    Replies: 6
    Last Post: Apr 12th, 2005, 04:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •