<tfoot id='D7tvT'></tfoot>
<legend id='D7tvT'><style id='D7tvT'><dir id='D7tvT'><q id='D7tvT'></q></dir></style></legend>
        <i id='D7tvT'><tr id='D7tvT'><dt id='D7tvT'><q id='D7tvT'><span id='D7tvT'><b id='D7tvT'><form id='D7tvT'><ins id='D7tvT'></ins><ul id='D7tvT'></ul><sub id='D7tvT'></sub></form><legend id='D7tvT'></legend><bdo id='D7tvT'><pre id='D7tvT'><center id='D7tvT'></center></pre></bdo></b><th id='D7tvT'></th></span></q></dt></tr></i><div id='D7tvT'><tfoot id='D7tvT'></tfoot><dl id='D7tvT'><fieldset id='D7tvT'></fieldset></dl></div>

      1. <small id='D7tvT'></small><noframes id='D7tvT'>

        • <bdo id='D7tvT'></bdo><ul id='D7tvT'></ul>

        SQLServer express R2 的 JDBC 连接 URL

        时间:2023-10-15

          <bdo id='3jUii'></bdo><ul id='3jUii'></ul>
        • <small id='3jUii'></small><noframes id='3jUii'>

        • <i id='3jUii'><tr id='3jUii'><dt id='3jUii'><q id='3jUii'><span id='3jUii'><b id='3jUii'><form id='3jUii'><ins id='3jUii'></ins><ul id='3jUii'></ul><sub id='3jUii'></sub></form><legend id='3jUii'></legend><bdo id='3jUii'><pre id='3jUii'><center id='3jUii'></center></pre></bdo></b><th id='3jUii'></th></span></q></dt></tr></i><div id='3jUii'><tfoot id='3jUii'></tfoot><dl id='3jUii'><fieldset id='3jUii'></fieldset></dl></div>
          <tfoot id='3jUii'></tfoot>
              <tbody id='3jUii'></tbody>

                  <legend id='3jUii'><style id='3jUii'><dir id='3jUii'><q id='3jUii'></q></dir></style></legend>
                  本文介绍了SQLServer express R2 的 JDBC 连接 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  I wrote the below line for connection with sql server express r2:

                  Connection con=DriverManager.getConnection("jdbc:sqlserver://localhost/SQLEXPRESS;databaseName=abc","sa","password");

                  It is giving exception: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost/SQLEXPRESS, port 1433 has failed. Error: "null. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".

                  I followed the line to solve the exception:

                  TCP/IP for SQL Server Express By default, TCP/IP for SQL Server Express is disabled, so JDBC cannot connect to it and you may get the following exception …

                  Network error IOException: Connection refused: connect Enable TCP/IP

                  To enable TCP/IP, start SQL Server Configuration Manager.

                  Expand SQL Server 2005 Network Configuration node. In the right pane, select Protocols for SQLEXPRESS. The right pane should now show Protocols and Status columns. Select Enable from the TCP/IP context menu. Find or Configure TCP/IP Port

                  After enabling TCP/IP, you have to find out which port number to use. SQL Server Express allocates a port dynamically each time it is started, so to find or configure the port number, continue using SQL Server Configuration Manager …

                  Select Properties from the TCP/IP context menu. The TCP/IP Properties dialog should open. Select the IP Addresses tab. In the IPAll node … The TCP Dynamic Ports field shows the currently used port number. If you set that field to blank, then SQL Server Express should not automatically choose another port when it restarts. Set the desired port number in the TCP Port field. Press OK to apply your settings and close the dialog.

                  After that also connection giving same exception.

                  解决方案

                  Try running some Java code to test it. Replace {computer-name}SQLEXPRESS with the domain that you see in the root node of SQL Server Management Studio. When installing SQL Express, you had the option to change the name of "SQLEXPRESS" to something custom, so that might also be different. To get the port number, go to Windows Start Menu > SQL Server 2008 R2 > Configuration Tools > SQL Server Configuration Manager > expand "SQL Server Network Configuration" > Click "Protocols for SQLEXPRESS" > right click "TCP/IP" and choose Properties > click "IP Addresses" tab/menu > in Windows XP, you will see "IPAll" .. look at the port there. It should default to 1433. If you have 2 version of SQL Express, then it might be different. Also make sure your service is running (has status of "Started") in Windows Control Panel > Administrative Tools > Services > SQL Server (SQLEXPRESS). Windows 7 is slightly different, but you'll find it.

                  The double backslashes need to be in a Java string. That just prints a single backslash during run time because it's an escape sequence.

                  import java.sql.*;
                  
                  public class TestConnection
                  {
                      public static void main(String[] args)
                      {
                          DB db = new DB();
                          db.dbConnect("jdbc:sqlserver://{computer-name}\SQLEXPRESS:1433;databaseName=abc;integratedSecurity=true;","sa","password");
                      }
                  }
                  
                  class DB
                  {
                      public DB() {}
                  
                      public void dbConnect(String db_connect_string, String db_userid, String db_password)
                      {
                          try
                          {
                              Connection conn = DriverManager.getConnection(db_connect_string, db_userid, db_password);
                              System.out.println("connected");
                          }
                          catch (Exception e)
                          {
                              e.printStackTrace();
                          }
                      }
                  };
                  

                  这篇关于SQLServer express R2 的 JDBC 连接 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:将序列化数组传递给 struts2 动作 下一篇:接收 SQLException “用户登录失败"连接到 SQL Server 2008

                  相关文章

                      <i id='6q6dA'><tr id='6q6dA'><dt id='6q6dA'><q id='6q6dA'><span id='6q6dA'><b id='6q6dA'><form id='6q6dA'><ins id='6q6dA'></ins><ul id='6q6dA'></ul><sub id='6q6dA'></sub></form><legend id='6q6dA'></legend><bdo id='6q6dA'><pre id='6q6dA'><center id='6q6dA'></center></pre></bdo></b><th id='6q6dA'></th></span></q></dt></tr></i><div id='6q6dA'><tfoot id='6q6dA'></tfoot><dl id='6q6dA'><fieldset id='6q6dA'></fieldset></dl></div>
                      <legend id='6q6dA'><style id='6q6dA'><dir id='6q6dA'><q id='6q6dA'></q></dir></style></legend>

                    1. <small id='6q6dA'></small><noframes id='6q6dA'>

                        <bdo id='6q6dA'></bdo><ul id='6q6dA'></ul>
                      <tfoot id='6q6dA'></tfoot>