It depends on what you are actually trying to do. My reading of your question is that you want the mainframe-based process to access the SQL Server database, and then do something with the result, possibly using a 3270 terminal.
If you can use Unix System Services, you can compile a TDS library, such as FreeTDS , and then use the C program to execute you want to get the result. If you want to complicate the work, you can start the connection from your own z / OS environment by compiling the code using IBM C, SAS C or Dignus C / C ++ . I can recommend Dignus, and I used it to create code that interacts with other languages ββon z / OS. The Dignus headers and the runtime library have (from memory) some FreeBSD lines that help simplify porting.
Using this approach, you can get a boot module that you can call from some other part of your system to do this job, you can link the code to other parts of your system or just send a request and get an exit.
If you want to use Java, you can use something like jTDS and write Java code to do what you need. I did not use Java on z / OS, so I cannot offer specific recommendations there, but I used jTDS on other platforms, and I was pleased with the result.
Update:
You can export the C function as an entry point to the load module, and then call it from Cobol. A C / C ++ implementation must deal with Cobol data structures; they are well defined and predictable, so this is not a problem. Depending on how flexible you need things, you can compile the request into C code and just have a function that executed a predefined request and had an interface to get the result, or you could have something more complex where the request was provided from Cobol programs.
I used this approach to provide API functions for Adabas / Natural developers, and it worked well. The Dignus compiler has a mechanism for callers to provide a runtime library descriptor so that you can control the lifetime of the C runtime from the calling program.
For a C / C ++ developer, this should be fairly simple. If your developers are Cobol developers, things can be a little more complicated.
Access to the gateway is possible, and I am sure that there are gateway products, but I can not recommend it. I saw trashy ones that I would not recommend, but that does not mean that somewhere is not right.
For completeness, I mentioned the possibility of implementing the TDS protocol in Cobol. It sounds like a cruel and ordinary punishment.