ОС: macOS Catalina 10.15.2 и Windows 10
Образ Docker: mcr.microsoft.com/mssql/server:2019-CU2-ubuntu-16.04(2019 GA имеет ту же проблему)
Драйвер JDBC: com.microsoft.sqlserver:mssql-jdbc:8.2.1.jre8
Контекст:
Запуск базы данных в контейнере докера и доступ через драйвер JDBC.
Я запускаю контейнер докера, используя https://github.com/testcontainers/testc ... s-java/api
Поведение:
Запуск базы данных проходит нормально, и я получаю:
Код: Выделить всё
[01/24/2020 14:53:23:405 CST] 051 SQLServerContainer output I
2020-01-24 20:53:23.41 spid12s Clearing tempdb database.
Код: Выделить всё
-- Create database
CREATE DATABASE TEST;
-- Enable XA connections
EXEC sp_sqljdbc_xa_install;
Код: Выделить всё
...
[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).
Код: Выделить всё
[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.
Чего я пытаюсь достичь в своем исходном коде:
Код: Выделить всё
/**
* 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;
}
}
- Не должна ли инициализация MSDTC происходить во время выполнения
хранимая процедура?
Код: Выделить всё
EXEC sp_sqljdbc_xa_install; - Почему между хранимыми процедурами такая большая задержка?
- Почему мы зависаем на последней хранимой процедуре?
- Это проблема с образом Docker или драйвером JDBC? (Это работало в derby, db2, postgres и oracle)
Подробнее здесь: https://stackoverflow.com/questions/601 ... d-stored-p
Мобильная версия