Betriebssystem: macOS Catalina 10.15.2 und Windows 10
Docker Image: mcr.microsoft.com/mssql/server:2019-CU2-ubuntu-16.04(2019 GA hat das gleiche Problem)
JDBC Treiber: com.microsoft.sqlserver:mssql-jdbc:8.2.1.jre8
Kontext:
Datenbank im Docker-Container ausführen und über JDBC-Treiber darauf zugreifen.
Ich starte den Docker-Container mit https://github.com/testcontainers/testcontainers-java/ api
Verhalten:
Der Start der Datenbank verläuft einwandfrei und ich erhalte Folgendes:
Code: Select all
[01/24/2020 14:53:23:405 CST] 051 SQLServerContainer output I
2020-01-24 20:53:23.41 spid12s Clearing tempdb database.
Code: Select all
-- Create database
CREATE DATABASE TEST;
-- Enable XA connections
EXEC sp_sqljdbc_xa_install;
Code: Select all
...
[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).
Code: Select all
[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.
Was ich mit meinem Quellcode erreichen möchte:
Code: Select all
/**
* 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;
}
}
- Sollte die Initialisierung von MSDTC nicht während der Ausführung von
erfolgen?gespeicherte Prozedur?Code: Select all
EXEC sp_sqljdbc_xa_install; - Warum gibt es eine so lange Verzögerung zwischen gespeicherten Prozeduren?
- Warum bleiben wir bei der letzten gespeicherten Prozedur hängen?
- Ist das ein Problem mit dem Docker-Image oder dem JDBC-Treiber? (Dies funktionierte auf Derby, DB2, Postgres und Oracle)
Mobile version