各位富翁,帮帮我吧,关于microsoft的TYPE 4型的那个JDBC驱动!(100分)

  • 主题发起人 主题发起人 KervenLee
  • 开始时间 开始时间
K

KervenLee

Unregistered / Unconfirmed
GUEST, unregistred user!
出错提示为
Exception in thread "main"java.lang.NoClassDefUndError:com/microsoft/util/UtilDummyPrintWriter
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(class.java:120)
at Selector.main(Selector.java:20)
我的代码如下:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;

public class Selector
{
public static void main(String[] args)
{
String url = "jdbc:microsoft:sqlserver://kevin:1433;DataBaseName=Northwind";
Connection con = null;

try
{
String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";

Class.forName(driver).newInstance();
}
catch (Exception e)
{
System.out.println("Failed to load Microsoft SQL Server 2000 Driver.");
e.printStackTrace();
return;
}

try
{
con = DriverManager.getConnection(url,"sa","");

Statement select = con.createStatement();

ResultSet result = select.executeQuery("SELECT FirstName,LastName from Employees");

System.out.println("Got results : ");

while(result.next())
{
String firstName;
String lastName;

firstName = result.getString(1);

lastName = result.getString(2);

if(result.wasNull())
{
return;

}

System.out.println("FirstName = "+firstName);
System.out.println("LastName = "+lastName);
}
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
if (con != null)
{
try
{
con.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}
}
 
找一下
com/microsoft/util/UtilDummyPrintWriter
在那个文件中,然后把它加入classpath
winzip可以打开jar文件

-----
http://www.8421.org
 
大哥,我加上啊,就是在那个msutil.jar中啊,我的classpath:
.;c:/jdk/mssqlserver.jar;c:/jdk/msutil.jar;,c:/jdk/msbase.jar;
 
接受答案了.
 
后退
顶部