我从网上下的三个sql server 2000的jdbc驱动包msbase.jar、mssqlserver.jar、msutil.jar,我把这三个包放在c:\sql目录下,classpaht为.;c:\sql\msbase.jar;c:\sql\mssqlserver.jar;c:\msutil.jar;为什么我程序老是提示ClassNotFound.操作系统为win2000 server。
代码:
import java.sql.*;
class Testj{
public static void main(String args[])
{
String RL = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=news";
String user ="sa";
String password = "";
String sqlStr = "select * from Admin_Info";
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
System.out.println( "类实例化成功!" );
System.out.println("slkdjf");
Connection con = DriverManager.getConnection(RL,user,password);
System.out.println( "创建连接对像成功!" );
Statement st = con.createStatement();
System.out.println( "创建Statement成功!" );
ResultSet rs = st.executeQuery( sqlStr );
System.out.println( "操作数据表成功!" );
System.out.println( "----------------!" );
while(rs.next())
{
System.out.print(rs.getInt("UserID") + " ");
System.out.print(rs.getString("UserName") + " ");
}
rs.close();
st.close();
con.close();
}
catch(Exception err){
err.printStackTrace(System.out);
}
}
}
编译通过,但运行时提示:
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at Testj.main(Testj.java:18)
希望各位大虾们明示
[此贴子已经被作者于2007-5-16 16:56:05编辑过]