0

I am using sql server 2008 r2 sql express. I usually connect to my sql like this: enter image description here

Now I want to connect to sql server 2008 r2 from my eclipse.

I searched google and I found that I have to download a jar file and I did and I added it to my project in eclipse.

my code is

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            String connectionUrl = "jdbc:sqlserver://localhost:1433;"
                    + "databaseName=DATABASE;user=User-PC\\User;password=;";

To be honest: I don't know if i should put localhost or sqlexpress and I don't know the password because as I should you in the image or I just use it empty.

the exception is :

The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. 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.".

I enable TCP/IP in my sql configuration

please help me

4

1 に答える 1

0

ここに画像の説明を入力

新しいユーザーを作成するときは、そのユーザーのログインを設定し、画像を確認して色付きのボタンを押し、ログインを選択する必要があります。

その後、文字列 url 接続を次のように変更します。

Class.forName(DB_DRIVER_NAME);
            String connectionString = "jdbc:sqlserver://" + DB_SERVER
                    + ";databaseName=" + DB_NAME + ";user=" + DB_USER
                    + ";password=" + DB_PASSWORD;
于 2013-04-28T15:50:43.967 に答える