我的java连接不上数据库sql server 2000
importjava.sql.*;publicclassTestDB{publicstaticvoidmain(String[]args){StringdriverNam...
import java.sql.*;
public class TestDB {
public static void main(String[] args) {
String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String dbURL = "jdbc:microsoft:sqlserver://localhost:1433; DatabaseName=sqlserverdemo";
String userName = "sa";
String userPwd = "5538275";
Connection dbConn ;
try {
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
System.out.println("Connection Successful!");
}
catch (Exception e) {
e.printStackTrace();
}
}
}//产生的异常如下:
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 TestDB.main(TestDB.java:12)
各位如果能帮我解决成功 ,我另外加分!
大虾 们 ,帮帮小弟吧,如果能解决我一定另外加分的!小弟谢谢各位高手啦 展开
public class TestDB {
public static void main(String[] args) {
String driverName = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String dbURL = "jdbc:microsoft:sqlserver://localhost:1433; DatabaseName=sqlserverdemo";
String userName = "sa";
String userPwd = "5538275";
Connection dbConn ;
try {
Class.forName(driverName);
dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
System.out.println("Connection Successful!");
}
catch (Exception e) {
e.printStackTrace();
}
}
}//产生的异常如下:
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 TestDB.main(TestDB.java:12)
各位如果能帮我解决成功 ,我另外加分!
大虾 们 ,帮帮小弟吧,如果能解决我一定另外加分的!小弟谢谢各位高手啦 展开
3个回答
展开全部
java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
楼上的说的对
楼上的说的对
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
类文件没有导入
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询