public class DataBaseConnection{ private static Connection conn; static{ try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } } public static Connection getConnection(){ try { if(conn == null || conn.isClosed()){ conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;database=uploadSystem;user=sa;password=amwgdyce"); } } catch (SQLException ex) { ex.printStackTrace(); } finally { return conn; } }}
Microsoft SQLServer 2000 Driver forJDBC Error establishing socket到底怎么解决啊?
------解决方法--------------------------------------------------------
http://www.java2000.net/p394
看第八条
8) 在 SQL Server 2005 里面,如果出现
到主机 的 TCP/IP 连接失败。 java.net.ConnectException: Connection refused: connect
sqlserver2005默认情况下是禁用了tcp/ip连接。启动tcp/ip连接的方法,
打开 \Microsoft SQL Server 2005\配置工具\目录下的SQL Server Configuration Manager,选择mssqlserver协议,
然后右边窗口有个tcp/ip协议,然后启动它,把sqlserver服务停了,然后在启动。问题就解决了