<%Connection con ;
Statement st ;
String sql = "select * FROM [test].[dbo].[student]";
String url = "jdbc:sqlserver://localhost;database=test";
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(url,"sa","123456");
st = con.createStatement();
ResultSet rs = st.executeQuery(sql);
out.print(rs.getString("name"));
rs.close();
st.close();
%>
一直连不上去,刚开始一直说
[color=#993300]Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");[/color]
这句报错,改了改就成下面的错误了。
下载了一个sqljdbc4.jar到lib里面。
message javax.servlet.ServletException: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: Connection refused: connect. Please verify the connection properties and check that a SQL Server instance is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.description The server encountered an internal error that prevented it from fulfilling this request.
Statement st ;
String sql = "select * FROM [test].[dbo].[student]";
String url = "jdbc:sqlserver://localhost;database=test";
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(url,"sa","123456");
st = con.createStatement();
ResultSet rs = st.executeQuery(sql);
out.print(rs.getString("name"));
rs.close();
st.close();
%>
一直连不上去,刚开始一直说
[color=#993300]Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");[/color]
这句报错,改了改就成下面的错误了。
下载了一个sqljdbc4.jar到lib里面。
message javax.servlet.ServletException: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: Connection refused: connect. Please verify the connection properties and check that a SQL Server instance is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.description The server encountered an internal error that prevented it from fulfilling this request.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货