SQL2000 关于 Java JDBC 驱动的安装和设定,SQL2000 关于 Java JDBC 驱动的安装和设定
【 tulaoshi.com - SQLServer 】
解决方法摘自 studyhardlr 『http://www.javathinker.org/bbs/topic.jsp?db=7&topic=3749』1、首先要记得sql2000 要打上sp3以上的补丁.(建议用sp4)
2、装上SQL Server 2000 Driver for JDBC Service Pack 3
下载地址:http://www.microsoft.com/downloads/details.aspx?FamilyId=07287B11-0502-461A-B138-2AA54BFDC03A&displaylang=en
3、安装完SQL Server 2000 Driver for JDBC Service Pack 3,它默认安装在C:Program FilesMicrosoft SQL Server 2000 Driver for JDBC 里,在C:Program FilesMicrosoft SQL Server 2000 Driver for JDBClib 这个目录里有三个jar文件:
msbase.jar,mssqlserver.jar,msutil.jar,一定要记得把这三个文件copy到你所安装的jdk下的jre目里,这里我以的我的安装配置进行解说:
我的jdk是jdk1.5.0_09,默认安装在:
C:Program FilesJava 里,在这个C:Program FilesJava目录下有两个文件夹:
jdk1.5.0_09 目录 和 jre1.5.0_09目录,
前面说的的那三个jar文件一定要copy到jdk1.5.0_09目录里下的jre目录下的lib目录下的ext目录下,我这里的完整路径为:
C:Program FilesJavajdk1.5.0_09jrelibext
4、设置classpath,把这个三个jar文件,加进去
5、sql2000要设置为混合登录模式(windows 和 sql)
-----------------------------------------------------------------------------------------------------------
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/sqlserver/)调用示例JAVA代码
----------------------------------------------------------------------------------------------------------
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.ResultSet;
//import java.*;
class CourseAppl {
private Connection conn;
private String url;
private String serverName;
private String portNumber;
private String databaseName;
private String userName;
private String password;
private String sql;
CourseAppl() {
url = "jdbc:microsoft:sqlserver://";
serverName = "localhost";
portNumber = "1433";
databaseName = "test";
userName = "sa";
password = "";
}
private String getConnectionUrl() {
//System.out.println (url + serverName + ":"
// + portNumber + ";databaseName="
//+ databaseName + ";");
return url + serverName + ":"
+ portNumber + ";databaseName="
+ databaseName + ";";
}
private Connection getConnection() {
try {
System.out.println (getConnectionUrl());
Class.forName("com.microsoft.jdbc.sqlserver.SQLSe
来源:http://www.tulaoshi.com/n/20160129/1496604.html
看过《SQL2000 关于 Java JDBC 驱动的安装和设定》的人还看了以下文章 更多>>