sqlexception 异常 求助高手

来源:百度知道 编辑:UC知道 时间:2024/06/03 07:10:12
程序如下
package sql;

import java.sql.*;
public class SqlTesting {
public static void main(String args[]) {
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Northwind";
String user ="";
String password = "";
String sqlStr = "select CustomerID, CompanyName, ContactName from Customers";

try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
System.out.println( "" );

Connection con = DriverManager.getConnection(url,user,password );
Statement st = con.createStatement();
ResultSet rs = st.executeQuery( sqlStr );

while(rs.next()) {
System.out.print(rs.getString("CustomerID") + " ");
System.out.print(rs.getString("CompanyName") + " ");
System.out.println(rs.getString("ContactName"));

你这是SQL Server 2000本身的问题,必须要打补丁。

你的SQL Server 2000需要打补丁,至少是sp3,我给你一个地址是sp4的, 你下栽安装就可以了。你可以自己上网搜索,或去微软网站下栽。你的这个问题就是没有打补丁。
http://www.onlinedown.net/soft/16338.htm

localhost改成计算机名或ip地址

连接字符串出错了,不过没用过爪哇,帮不了你,给你一个连接字符串网站吧:
http://www.connectionstrings.com/