当前位置: 技术问答>java相关
怎么连接sql server,不用jdbc:odbc桥
来源: 互联网 发布时间:2017-03-22
本文导语: 怎么连接sql server,不用jdbc:odbc桥 | Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://192.168.0.9:1433;user=sa;password=sa;DatabaseName=testDb"); | ...
怎么连接sql server,不用jdbc:odbc桥
|
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://192.168.0.9:1433;user=sa;password=sa;DatabaseName=testDb");
Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://192.168.0.9:1433;user=sa;password=sa;DatabaseName=testDb");
|
http://msdn.microsoft.com/MSDN-FILES/027/001/779/JDBCRTMReleaseMa
nifest.htm
1. Download theMicrosoft SQL Server 2000 Driver for JDBC (setup.exe file) from
the Microsoft MSDN Web site at
http://msdn.microsoft.com/downloads/default.asp?URL=/downloads/
sample.asp?url=/MSDN-FILES/027/001/779/msdncompositedoc.xml.
Save the file in a temporary directory on your local computer.
2. Run setup.exe from the temporary directory and follow the instructions on the
screen.
3. Add the path to the following files to your CLASSPATH:
" install_dir/lib/msbase.jar
" install_dir/lib/msutil.jar
" install_dir/lib/mssqlserver.jar
Where install_dir is the folder in which you installed the driver. For
example:
set CLASSPATH=install_dirlibmsbase.jar;
install_dirlibmsutil.jar;install_dirlibmssqlserver.jar;
%CLASSPATH%
DriverName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
URL="jdbc:microsoft:sqlserver://lcdbnt4:1433"
nifest.htm
1. Download theMicrosoft SQL Server 2000 Driver for JDBC (setup.exe file) from
the Microsoft MSDN Web site at
http://msdn.microsoft.com/downloads/default.asp?URL=/downloads/
sample.asp?url=/MSDN-FILES/027/001/779/msdncompositedoc.xml.
Save the file in a temporary directory on your local computer.
2. Run setup.exe from the temporary directory and follow the instructions on the
screen.
3. Add the path to the following files to your CLASSPATH:
" install_dir/lib/msbase.jar
" install_dir/lib/msutil.jar
" install_dir/lib/mssqlserver.jar
Where install_dir is the folder in which you installed the driver. For
example:
set CLASSPATH=install_dirlibmsbase.jar;
install_dirlibmsutil.jar;install_dirlibmssqlserver.jar;
%CLASSPATH%
DriverName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
URL="jdbc:microsoft:sqlserver://lcdbnt4:1433"
|
如果用JRUN可以用自带的JDBC比较方便