sql Server与eclipse的连接的问题
弄了好几天,也没有找到错误的原因
我的安装的是jdk1.4,安装路径是 D:\j2sdk;
我已经把msbase.jar;mssqlserver.jar;msutil.jar放到D:\j2sdk\jre\lib\ext的目录下面;
路径的配置为:
CLASSPATH=.\;%JAVA_HOME%\lib\tools.jar;D:\j2sdk\jre\lib\ext
JAVA_HOME=D:\j2sdk
Path=D:\j2sdk\jre\lib\ext
连接数据库的语句为
import java.sql.*;
public class Datalink {
private Connection con;//建立连接
/** Creates a new instance of Datalink */
public Datalink() {
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}catch(Exception e){
System.out.println("加载数据库驱动程序失败,请检查数据库驱动");
}
try{
this.con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;" +
"DatabaseName=java","ja","ja");
}catch(SQLException ee){
System.out.println("执行数据库查询失败,请检查连接");
System.out.println(ee.getClass());
System.out.println(ee.getMessage());
}
}
public Connection getConnection(){
return this.con;
}
}
提示错误:加载数据库驱动程序失败,请检查数据库驱动
执行数据库查询失败,请检查连接
class java.sql.SQLException
No suitable driver
试图连接数据库失败.
各位大侠。错误的原因在那。希望大侠指点