Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8366241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:52:03+00:00 2026-06-09T12:52:03+00:00

I have main data source for working with database, which uses some connection pool.

  • 0

I have main data source for working with database, which uses some connection pool. Now I want to create a second data source, which would use the same connection pool to perform logging operations in a separate transaction, then main database transaction! As far as I understood from the Glassfish docs if multiple data sources are using the same connection pool, then they share a transaction until connection is not closed (I might be wrong, please correct me).

So, is there a way to start a new transaction, when getting a connection to a data source? By setting TransactionIsolation may be?

Connection is retrieved in the following way:

private synchronized Connection getConnection() {
        if (connection == null) {
            try {
                final Context ctx = new InitialContext();
                final DataSource ds = (DataSource) ctx.lookup(getDataSourceLookupAddress());
                connection = ds.getConnection();
            } catch (final NamingException e) {
                errorHandler.error("Datasource JNDI lookup failed: " + dataSourceLookupAddress + "!");
                errorHandler.error(e.toString());
            } catch (final SQLException e) {
                errorHandler.error("Sql connection failed to " + dataSourceLookupAddress + "!");
                errorHandler.error(e.toString());
            }
        }
        return connection;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:52:04+00:00Added an answer on June 9, 2026 at 12:52 pm

    I have figured it out. It’s necessary to start a new Thread, then a new transaction will be created. See also Writing to database log in the middle of rollback

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that uses three JTextField fields as the main data entry
I have one main array which is the returned data from a MySQL query
I have a WPF4 application i have 1 window which editing data : main
I have a grid view in my main page and I display some data
I have created an application which inserts data into a SQL database. Basically, from
I have been working with managing agile teams for quite some time. Now I'm
I have a problem with a large database I am working with which resides
I have a custom Data Source, let's call it SQSDatasource . It's working fine,
I have a main SQL Server A that data is inserted into. The table
I have a document-based Core Data app. My main Core Data entity has several

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.