SQL2000 关于 Java JDBC 驱动的安装和设定
解决方法摘自 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 Files\Microsoft SQL Server 2000 Driver for JDBC 里,在C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib 这个目录里有三个jar文件: msbase.jar,mssqlserver.jar,msutil.jar,一定要记得把这三个文件copy到你所安装的jdk下的jre目里,这里我以的我的安装配置进行解说: 我的jdk是jdk1.5.0_09,默认安装在: C:\Program Files\Java 里,在这个C:\Program Files\Java目录下有两个文件夹: jdk1.5.0_09 目录 和 jre1.5.0_09目录, 前面说的的那三个jar文件一定要copy到jdk1.5.0_09目录里下的jre目录下的lib目录下的ext目录下,我这里的完整路径为: C:\Program Files\Java\jdk1.5.0_09\jre\lib\ext
4、设置classpath,把这个三个jar文件,加进去
5、sql2000要设置为混合登录模式(windows 和 sql)
-----------------------------------------------------------------------------------------------------------
调用示例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 + ";"; |