下面两句话老是出错,原因不明,我装过了JDBC驱动了,环境变量也设好了。我也将三个sbase.jar,mssqlserver.jar,msutil.jar文件Copy到了\j2sdk1.4.2_09\jre\lib\ext目录下但是在Eclipse加这两句就出错, Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver:DatabaseName=abc");
Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver:DatabaseName=abc");
eclipse的classpath是它内部的,并不是系统环境变量设置那边的classpath
----------------------------------------------------
换成"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=books","sa",""
如果还有问题,可以参考以下文章:
http://www.blogjava.net/rickhunter/category/3664.html
上边的没错,然后
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver:DatabaseName=abc");
} catch (Exception e1) {
// TODO 自动生成 catch 块
e1.printStackTrace();
}
再不明白我也没办法了,^_^
从这句还是基本都有错》Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
Connection con=DriverManager.getConnection(URL,NM,PSW);
Statement stmt=con.createStatement();
ResultSet rst=stmt.executeQuery(strSQL);
readset=rst;
while (rst.next())
{
intStr=Suc;
rst.beforeFirst();
}
未处理的异常类型 IllegalAccessException
未处理的异常类型 InstantiationException
未处理的异常类型 SQLException