Hello team,
We are making a POC for webMethods Integration Server CICD, so everything is based on docker.
When try with MySQL 8.0, all works good, but when try to connect to SQL Server(I tried both 2019 and 2022)
The console throws the following error:
```
jvm 1 | ,errorCode=204,errorMessageArgs=[0]com.microsoft.sqlserver.jdbc.SQLServerDataSource,[1]
jvm 1 | (08S01/0) The TCP/IP connection to the host host.docker.internal, port 1443 has failed. Error: "Connection refused. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".,errorResourceBundleName=com.wm.adapter.wmjdbc.JDBCAdapterResourceBundle,detail=null<<<,stack=com.wm.adk.error.AdapterConnectionException: [ADA.1.204] Cannot connect to the database with DataSource class "com.microsoft.sqlserver.jdbc.SQLServerDataSource".
jvm 1 | The TCP/IP connection to the host host.docker.internal, port 1443 has failed. Error: "Connection refused. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
jvm 1 | at com.wm.adk.WmAdapter.createAdapterConnectionException(WmAdapter.java:276)
jvm 1 | at com.wm.adapter.wmjdbc.connection.ConnectionInfo.handleSQLException(ConnectionInfo.java:782)
jvm 1 | at com.wm.adapter.wmjdbc.connection.ConnectionInfo.handleSQLException(ConnectionInfo.java:793)
jvm 1 | at com.wm.adapter.wmjdbc.connection.JDBCConnection.initializeConnection(JDBCConnection.java:397)
```
I even tried with the simplest java JDBC code within webMethods docker container, it works without any problem. So there shouldn't be any network issue here.
```sh
# Test on my macOS, pass
$ javac Test.java
$ tree -L 1
.
├── mssql-jdbc-12.4.2.jre11.jar
├── Test.class
├── Test.java
$ java -cp .:mssql-jdbc-12.4.2.jre11.jar Test
Connecting to SQL Server...
Creating statement...
ID: 1, Email: james.smith@example.com
ID: 2, Email: emily.johnson@example.com
ID: 3, Email: michael.w@example.com
ID: 4, Email: sarah.brown@example.com
ID: 5, Email: david.jones@example.com
Connection closed.
# Copy to webMethods docker container
docker cp Test.class webMethods:/tmp/
docker exec -it webMethods bash
cd /tmp/
# Test Pass
/opt/softwareag/jvm/jvm/bin/java -cp .:/opt/softwareag/IntegrationServer/instances/default/packages/WmJDBCAdapter/code/jars/static/mssql-jdbc-12.4.2.jre11.jar Test
Connecting to SQL Server...
Creating statement...
ID: 1, Email: james.smith@example.com
ID: 2, Email: emily.johnson@example.com
ID: 3, Email: michael.w@example.com
ID: 4, Email: sarah.brown@example.com
ID: 5, Email: david.jones@example.com
Connection closed.
```
Here is my docker file
```dockerfile
FROM ibmwebmethods.azurecr.io/webmethods-integrationserver:10.15
ADD --chown=sagadmin:sagadmin WmJDBCAdapter /opt/softwareag/IntegrationServer/instances/default/packages/WmJDBCAdapter
ADD --chown=sagadmin:sagadmin mssql-jdbc-12.4.2.jre11.jar /opt/softwareag/IntegrationServer/instances/default/packages/WmJDBCAdapter/code/jars/static/
ADD --chown=sagadmin:sagadmin mysql-connector-j-8.3.0.jar /opt/softwareag/IntegrationServer/instances/default/packages/WmJDBCAdapter/code/jars/static/
```
Here is the configuration page for MySQL (worked) ✅

Here is the configuration page for SQL Server 2019/2022, (not work) ❌

Java Code inside webMethods works ✅
```java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class Test {
public static void main(String[] args) {
String jdbcUrl = "jdbc:sqlserver://host.docker.internal:1433;databaseName=night_elf;encrypt=true;trustServerCertificate=true";
String username = "sa";
String password = "ThisisS0me_password";
Connection connection = null;
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
System.out.println("Connecting to SQL Server...");
connection = DriverManager.getConnection(jdbcUrl, username, password);
System.out.println("Creating statement...");
Statement statement = connection.createStatement();
String sql = "SELECT TOP 5 * FROM CUSTOMERS";
ResultSet resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
int id = resultSet.getInt("customer_id");
String email = resultSet.getString("email");
System.out.println("ID: " + id + ", Email: " + email);
}
resultSet.close();
statement.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (connection != null) {
connection.close();
System.out.println("Connection closed.");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
```
Lastly, let me also paste docker-compose file for SQL Server.
```yml
version: '3.8'
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2022-latest
container_name: sqlserver
environment:
ACCEPT_EULA: "Y"
MSSQL_SA_PASSWORD: "ThisisS0me_password"
ports:
- "1433:1433"
volumes:
- sqlserverdata:/var/opt/mssql
volumes:
sqlserverdata:
```