在线等个JAVA 和SQL2000 不通过连接池的问题?
我的程序;
import java.sql.*;
public class sqllink
{
public static void main (String[] args ) throws
ClassNotFoundException,
SQLException {
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ");
String str = "jdbc:microsoft:sqlserver://192.168.50.60:1433;DatabaseName=student ";
String user = "sa ";
String pass = "software ";
Connection conn = DriverManager.getConnection(str,user,pass);
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql = "select * from student ";
ResultSet rs = stmt.executeQuery(sql);
while(rs.next())
{
System.out.print(rs.getString(0));
System.out.print(rs.getString(1));
System.out.print(rs.getString(2));
}
rs.close();
stmt.close();
conn.close();
}
}编译后有个错误:
Exception in thread "main "
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 wangsong.data.sqllink.main(sqllink.java:9)
我想估计是驱动的问题,但是我把msbase.jar,mssqlserver.jar,msutil.jar加到LIB 下还是这个错误,希望高手指教~
------解决方案--------------------在环境变量lib下添加详细的包路径
比如“你以前的lib参数”;d:\j2sdk1.4.1_01\lib\mssqlserver.jar;
------解决方案--------------------再环境变量中+;D:\j2sdk1.4.1_01\lib\msbase.jar;D:\j2sdk1.4.1_01\lib\mssqlserver.jar;D:\j2sdk1.4.1_01\lib\msutil.jar
------解决方案--------------------集成开发工具集