Connecting to SQL Server 2008 from Java

前端 未结 3 1850
我寻月下人不归
我寻月下人不归 2020-12-06 08:20

I am trying to connect to SQL Server 2008 server from Java

here is a program

import java.sql.*;

public class connectURL {

    public static void m         


        
相关标签:
3条回答
  • 2020-12-06 09:07

    Do you have localhost defined in your hosts file? Try replacing localhost with 127.0.0.1 in the connection url.

    ...and you have the SQL Server running in the same computer, right?

    0 讨论(0)
  • 2020-12-06 09:16

    I thing the connection URL may be wrong. Then try following connection,

     String Connectionurl="jdbc:sqlserver://localhost:1433;DatabaseName=YourDBName;user=UserName;Password=YourPassword"
    
    0 讨论(0)
  • 2020-12-06 09:17

    TCP/IP connections are disabled by default when you install the Express version of SQL Server. You need to run the SQL Server Configuration Manager and turn on TCP/IP. You also need to set the port it's listening on to 1433.

    0 讨论(0)
提交回复
热议问题