System Information: OS: macOS Catalina 10.15.2 and Windows 10

Docker Image: (2019 GA has same issue)

JDBC Driver: com.microsoft.sqlserver:mssql-jdbc:8.2.1.jre8

Context: Running database in docker container and accessing via JDBC driver.
I start the docker container using api

Behavior: Startup of database goes fine and I get:

[01/24/2020 14:53:23:405 CST] 051 SQLServerContainer output I 2020-01-24 20:53:23.41 spid12s Clearing tempdb database. 

I then execute an init-sqlserver.sql file to enable jdbc xa connection:

-- Create database CREATE DATABASE TEST; -- Enable XA connections EXEC sp_sqljdbc_xa_install; 

and I get

... [01/24/2020 14:53:23:969 CST] 051 SQLServerContainer output I 2020-01-24 20:53:23.97 spid52 Starting up database 'TEST'. ... [01/24/2020 14:53:24:377 CST] 001 ScriptUtils executeDatabaseScript I Executed database script from resources/init-sqlserver.sql in 855 ms. [01/24/2020 14:53:25:029 CST] 051 SQLServerContainer output I 2020-01-24 20:53:25.04 spid25s The tempdb database has 6 data file(s). 

When I actually try to use an xa connection I get:

[01/24/2020 14:53:47:496 CST] 051 SQLServerContainer output I 2020-01-24 20:53:47.49 spid53 Initializing Microsoft Distributed Transaction Coordinator (MS DTC) resource manager [820e1ea9-c921-4350-897e-a7534d9d1ed7] for server instance 8b0aca425794. This is an informational message only. No user action is required. [01/24/2020 14:53:47:504 CST] 051 SQLServerContainer output I 2020-01-24 20:53:47.50 spid53 Recovery of any in-doubt distributed transactions involving Microsoft Distributed Transaction Coordinator (MS DTC) has completed. This is an informational message only. No user action is required. [01/24/2020 14:59:44:692 CST] 051 SQLServerContainer output I 2020-01-24 20:59:44.71 spid62 Attempting to load library 'xplog70.dll' into memory. This is an informational message only. No user action is required. [01/24/2020 14:59:44:742 CST] 051 SQLServerContainer output I 2020-01-24 20:59:44.76 spid62 Using 'xplog70.dll' version '2019.150.4003' to execute extended stored procedure 'xp_msver'. This is an informational message only; no user action is required. 

And I hang on the last part indefinitely. You can also see there is an approx 6 minute hang between two of the steps.

What I am trying to accomplish in my source code:

 /** * Enlist a two-phase capable resource in a global transaction. */ public void getXAConnection() throws Exception { setUpTables(ds1); tran.begin(); try (Connection con1 = ds1.getConnection()) { PreparedStatement pstmt = con1.prepareStatement("insert into cities values (?, ?, ?)"); pstmt.setString(1, "Wanamingo"); pstmt.setInt(2, 1086); pstmt.setString(3, "Goodhue"); pstmt.executeUpdate(); pstmt.close(); tran.commit(); } catch (Throwable x) { try { tran.rollback(); } catch (Throwable t) { } throw x; } } 

Questions:

  1. Shouldn't the initialization of MSDTC happen during the execution of EXEC sp_sqljdbc_xa_install; stored procedure?
  2. Why is there such a long delay between stored procedures?
  3. Why do we hang on the last stored procedure?
  4. Is this an issue with the docker image or the JDBC driver? (This worked on derby, db2, postgres, and oracle)
6

1 Answer

The SQL Server may have one or more of the extended stored procedures disabled by default for security reasons.

If this is a non-production development environment, have you tried connecting to the SQL Server with an SQL Server administrator account?

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.