Is there any way to use JDBC to connect to local MS SQL without enabling TCP?












-1















Background: My local MS SQL database is configured as following:
TCP/IP disabled with dynamic port (default setting)



When using .Net to connect to my local database, I don't need to enable TCP connection in SQL Server Configuration Manager or specifying the port number in connection string. I just need to put this in app.config



<add name="MyDatabase" connectionString="Initial Catalog=MyDatabase;Data Source=localhostSQLEXPRESS;Integrated Security=SSPI;"/>


However, I have to enable TCP in order to connect to it using JDBC. I wonder whether there is any way to get around it?










share|improve this question























  • Why a C# and .Net tags are here, if you are asking about java?

    – vasily.sib
    Nov 26 '18 at 3:28






  • 1





    also, after just 3.52 seconds of googling i found this article at MS docs

    – vasily.sib
    Nov 26 '18 at 3:30











  • @vasily.sib That link does not really address the question though.

    – Mark Rotteveel
    Nov 26 '18 at 7:35











  • ok, another search ("jdbc named pipes") and here it is

    – vasily.sib
    Nov 26 '18 at 9:55











  • Found that .Net uses shared memory to connect to SQL server. Unfortunately I wasn't able to find any JDBC driver for SQL server which supports this protocol. My intent was to avoid enabling additional protocols when using JDBC(only shared memory is enabled by default). Since it's not possible in this case, I'd rather go with TCP than named pipe.

    – Laiwen Yi
    Dec 11 '18 at 6:55


















-1















Background: My local MS SQL database is configured as following:
TCP/IP disabled with dynamic port (default setting)



When using .Net to connect to my local database, I don't need to enable TCP connection in SQL Server Configuration Manager or specifying the port number in connection string. I just need to put this in app.config



<add name="MyDatabase" connectionString="Initial Catalog=MyDatabase;Data Source=localhostSQLEXPRESS;Integrated Security=SSPI;"/>


However, I have to enable TCP in order to connect to it using JDBC. I wonder whether there is any way to get around it?










share|improve this question























  • Why a C# and .Net tags are here, if you are asking about java?

    – vasily.sib
    Nov 26 '18 at 3:28






  • 1





    also, after just 3.52 seconds of googling i found this article at MS docs

    – vasily.sib
    Nov 26 '18 at 3:30











  • @vasily.sib That link does not really address the question though.

    – Mark Rotteveel
    Nov 26 '18 at 7:35











  • ok, another search ("jdbc named pipes") and here it is

    – vasily.sib
    Nov 26 '18 at 9:55











  • Found that .Net uses shared memory to connect to SQL server. Unfortunately I wasn't able to find any JDBC driver for SQL server which supports this protocol. My intent was to avoid enabling additional protocols when using JDBC(only shared memory is enabled by default). Since it's not possible in this case, I'd rather go with TCP than named pipe.

    – Laiwen Yi
    Dec 11 '18 at 6:55
















-1












-1








-1








Background: My local MS SQL database is configured as following:
TCP/IP disabled with dynamic port (default setting)



When using .Net to connect to my local database, I don't need to enable TCP connection in SQL Server Configuration Manager or specifying the port number in connection string. I just need to put this in app.config



<add name="MyDatabase" connectionString="Initial Catalog=MyDatabase;Data Source=localhostSQLEXPRESS;Integrated Security=SSPI;"/>


However, I have to enable TCP in order to connect to it using JDBC. I wonder whether there is any way to get around it?










share|improve this question














Background: My local MS SQL database is configured as following:
TCP/IP disabled with dynamic port (default setting)



When using .Net to connect to my local database, I don't need to enable TCP connection in SQL Server Configuration Manager or specifying the port number in connection string. I just need to put this in app.config



<add name="MyDatabase" connectionString="Initial Catalog=MyDatabase;Data Source=localhostSQLEXPRESS;Integrated Security=SSPI;"/>


However, I have to enable TCP in order to connect to it using JDBC. I wonder whether there is any way to get around it?







c# .net sql-server jdbc






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 26 '18 at 3:20









Laiwen YiLaiwen Yi

62




62













  • Why a C# and .Net tags are here, if you are asking about java?

    – vasily.sib
    Nov 26 '18 at 3:28






  • 1





    also, after just 3.52 seconds of googling i found this article at MS docs

    – vasily.sib
    Nov 26 '18 at 3:30











  • @vasily.sib That link does not really address the question though.

    – Mark Rotteveel
    Nov 26 '18 at 7:35











  • ok, another search ("jdbc named pipes") and here it is

    – vasily.sib
    Nov 26 '18 at 9:55











  • Found that .Net uses shared memory to connect to SQL server. Unfortunately I wasn't able to find any JDBC driver for SQL server which supports this protocol. My intent was to avoid enabling additional protocols when using JDBC(only shared memory is enabled by default). Since it's not possible in this case, I'd rather go with TCP than named pipe.

    – Laiwen Yi
    Dec 11 '18 at 6:55





















  • Why a C# and .Net tags are here, if you are asking about java?

    – vasily.sib
    Nov 26 '18 at 3:28






  • 1





    also, after just 3.52 seconds of googling i found this article at MS docs

    – vasily.sib
    Nov 26 '18 at 3:30











  • @vasily.sib That link does not really address the question though.

    – Mark Rotteveel
    Nov 26 '18 at 7:35











  • ok, another search ("jdbc named pipes") and here it is

    – vasily.sib
    Nov 26 '18 at 9:55











  • Found that .Net uses shared memory to connect to SQL server. Unfortunately I wasn't able to find any JDBC driver for SQL server which supports this protocol. My intent was to avoid enabling additional protocols when using JDBC(only shared memory is enabled by default). Since it's not possible in this case, I'd rather go with TCP than named pipe.

    – Laiwen Yi
    Dec 11 '18 at 6:55



















Why a C# and .Net tags are here, if you are asking about java?

– vasily.sib
Nov 26 '18 at 3:28





Why a C# and .Net tags are here, if you are asking about java?

– vasily.sib
Nov 26 '18 at 3:28




1




1





also, after just 3.52 seconds of googling i found this article at MS docs

– vasily.sib
Nov 26 '18 at 3:30





also, after just 3.52 seconds of googling i found this article at MS docs

– vasily.sib
Nov 26 '18 at 3:30













@vasily.sib That link does not really address the question though.

– Mark Rotteveel
Nov 26 '18 at 7:35





@vasily.sib That link does not really address the question though.

– Mark Rotteveel
Nov 26 '18 at 7:35













ok, another search ("jdbc named pipes") and here it is

– vasily.sib
Nov 26 '18 at 9:55





ok, another search ("jdbc named pipes") and here it is

– vasily.sib
Nov 26 '18 at 9:55













Found that .Net uses shared memory to connect to SQL server. Unfortunately I wasn't able to find any JDBC driver for SQL server which supports this protocol. My intent was to avoid enabling additional protocols when using JDBC(only shared memory is enabled by default). Since it's not possible in this case, I'd rather go with TCP than named pipe.

– Laiwen Yi
Dec 11 '18 at 6:55







Found that .Net uses shared memory to connect to SQL server. Unfortunately I wasn't able to find any JDBC driver for SQL server which supports this protocol. My intent was to avoid enabling additional protocols when using JDBC(only shared memory is enabled by default). Since it's not possible in this case, I'd rather go with TCP than named pipe.

– Laiwen Yi
Dec 11 '18 at 6:55














1 Answer
1






active

oldest

votes


















1














The Microsoft SQL Server JDBC driver is a Type 4 (pure Java) implementation, and it only supports TCP/IP sockets to communicate with SQL Server, therefor it requires TCP/IP to be enabled on the server instance. There is no workaround that magically allows you to connect otherwise.



As also indicated by the comment of vasily.sib, you can switch to jTDS which supports named pipes. See also Connecting to SQL Server LocalDB using JDBC. Just be aware that jTDS is lagging in supporting newer SQL Server versions and newer JDBC specifications.






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53474380%2fis-there-any-way-to-use-jdbc-to-connect-to-local-ms-sql-without-enabling-tcp%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    The Microsoft SQL Server JDBC driver is a Type 4 (pure Java) implementation, and it only supports TCP/IP sockets to communicate with SQL Server, therefor it requires TCP/IP to be enabled on the server instance. There is no workaround that magically allows you to connect otherwise.



    As also indicated by the comment of vasily.sib, you can switch to jTDS which supports named pipes. See also Connecting to SQL Server LocalDB using JDBC. Just be aware that jTDS is lagging in supporting newer SQL Server versions and newer JDBC specifications.






    share|improve this answer






























      1














      The Microsoft SQL Server JDBC driver is a Type 4 (pure Java) implementation, and it only supports TCP/IP sockets to communicate with SQL Server, therefor it requires TCP/IP to be enabled on the server instance. There is no workaround that magically allows you to connect otherwise.



      As also indicated by the comment of vasily.sib, you can switch to jTDS which supports named pipes. See also Connecting to SQL Server LocalDB using JDBC. Just be aware that jTDS is lagging in supporting newer SQL Server versions and newer JDBC specifications.






      share|improve this answer




























        1












        1








        1







        The Microsoft SQL Server JDBC driver is a Type 4 (pure Java) implementation, and it only supports TCP/IP sockets to communicate with SQL Server, therefor it requires TCP/IP to be enabled on the server instance. There is no workaround that magically allows you to connect otherwise.



        As also indicated by the comment of vasily.sib, you can switch to jTDS which supports named pipes. See also Connecting to SQL Server LocalDB using JDBC. Just be aware that jTDS is lagging in supporting newer SQL Server versions and newer JDBC specifications.






        share|improve this answer















        The Microsoft SQL Server JDBC driver is a Type 4 (pure Java) implementation, and it only supports TCP/IP sockets to communicate with SQL Server, therefor it requires TCP/IP to be enabled on the server instance. There is no workaround that magically allows you to connect otherwise.



        As also indicated by the comment of vasily.sib, you can switch to jTDS which supports named pipes. See also Connecting to SQL Server LocalDB using JDBC. Just be aware that jTDS is lagging in supporting newer SQL Server versions and newer JDBC specifications.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 26 '18 at 12:32

























        answered Nov 26 '18 at 7:33









        Mark RotteveelMark Rotteveel

        61.5k1478122




        61.5k1478122
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53474380%2fis-there-any-way-to-use-jdbc-to-connect-to-local-ms-sql-without-enabling-tcp%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Wiesbaden

            Marschland

            Dieringhausen