Does anyone have any experience with or know if it's possible to connect via JDBC to a local (same machine) installation of SQL Server using the Shared Memory Protocol?
I have a jRDC2 based app which I have connecting to the database fine using a TCP/IP connection, but I've been asked if it can use Shared memory Protocol instead.
I've disabled TCP/IP protocol on the SQL Server (Express) that I have installed for testing and based on what I've read in:
and a few other places, I've been trying to connect to the database just with a simple test app:
Before disabling TCP/IP connections on the SQL Server I checked using the first commented jdbcURL and the sql.Initialize2 line that the query runs OK, connecting via TCP/IP. All OK there.
But when I disable TCP/IP and try to form the correct jdbcURL for a Shared Memory connection, I get one of various errors:
I have found a few posts stating that the JDBC driver does not support the Shared Memory Protocol, but these were from 10+ years ago, so I'm hoping they're out of date.
Does anyone know how/if we can connect to a local SQL Server database with the Shared Memory Protocol?
Many thanks!
I have a jRDC2 based app which I have connecting to the database fine using a TCP/IP connection, but I've been asked if it can use Shared memory Protocol instead.
I've disabled TCP/IP protocol on the SQL Server (Express) that I have installed for testing and based on what I've read in:

Using the JDBC Driver | Using Java with InterSystems Software | InterSystems IRIS Data Platform 2024.3
This chapter discusses how to establish a JDBC connection between your application and InterSystems IRIS, and how to use the JDBC driver’s extension methods and
docs.intersystems.com

SqlConnection.ConnectionString Property (System.Data.SqlClient)
Gets or sets the string used to open a SQL Server database.
learn.microsoft.com
and a few other places, I've been trying to connect to the database just with a simple test app:
B4X:
'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
Private sql As SQL
End Sub
'DB drivers.
'MSSQL
#AdditionalJar: mssql-jdbc-12.6.2.jre11
Sub AppStart (Args() As String)
Dim drvClass As String = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
' Dim jdbcURL As String = "jdbc:sqlserver://SERVERNAME:PORTNUM;instanceName=sqlexpress;databaseName=DBNAME;encrypt=true;trustServerCertificate=True"
' Dim jdbcURL As String = "jdbc://lpc:localhost;instanceName=sqlexpress;databaseName=DBNAME;"
' Dim jdbcURL As String = "jdbc:sqlserver://lpc:(local);instanceName=sqlexpress;databaseName=DBNAME;"
' Dim jdbcURL As String = "jdbc:sqlserver:lpc:(local);instanceName=sqlexpress;databaseName=DBNAME;"
' Dim jdbcURL As String = "jdbc:sqlserver://(local);instanceName=sqlexpress;databaseName=DBNAME;"
' Dim jdbcURL As String = "jdbc:sqlserver://(local)\sqlexpress;databaseName=DBNAME;"
Dim jdbcURL As String = "jdbc:sqlserver://localhost\sqlexpress;databaseName=DBNAME;"
' sql.Initialize2(drvClass, jdbcURL, usr, pw)
sql.Initialize(drvClass, jdbcURL)
Log("Number of rows = " & sql.ExecQuerySingleResult("SELECT count(*) FROM TABLE1"))
sql.Close
End Sub
Before disabling TCP/IP connections on the SQL Server I checked using the first commented jdbcURL and the sql.Initialize2 line that the query runs OK, connecting via TCP/IP. All OK there.
But when I disable TCP/IP and try to form the correct jdbcURL for a Shared Memory connection, I get one of various errors:
B4X:
java.sql.SQLException: No suitable driver found for jdbc:sqlserver:lpc:(local);instanceName=sqlexpress;databaseName=DBNAME;
com.microsoft.sqlserver.jdbc.SQLServerException: The port number (local) is not valid.
com.microsoft.sqlserver.jdbc.SQLServerException: The connection to the host (local), named instance sqlexpress failed. Error: "java.net.UnknownHostException: (local)". Verify the server and instance names and check that no firewall is blocking UDP traffic to port 1434. For SQL Server 2005 or later, verify that the SQL Server Browser Service is running on the host.
I have found a few posts stating that the JDBC driver does not support the Shared Memory Protocol, but these were from 10+ years ago, so I'm hoping they're out of date.
Does anyone know how/if we can connect to a local SQL Server database with the Shared Memory Protocol?
Many thanks!