SQL Server 2005 Driver for JDBC

夏飞鹏
2023-12-01
  1. Load the SQL Server 2005 Driver for JDBC before you load the SQL Server 2000 Driver for JDBC. To do this, use the DriverManager class as in the following code example.
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); // 2005 version
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); // 2000 version
  2. Use a SQL Server 2005 Driver for JDBC connection URL to establish a connection. To do this, use code that resembles the following code example.
    Connection con = DriverManager.getConnection("jdbc:sqlserver://<ServerName>;user=<UserName>;password=<Password>");

For more information about how to connect with data sources and how to use a connection URL, visit the following Microsoft Developer Network (MSDN) Web sites:

Building the connection URL
http://msdn2.microsoft.com/en-us/library/ms378428.aspx (http://msdn2.microsoft.com/en-us/library/ms378428.aspx)

Setting the connection properties
http://msdn2.microsoft.com/en-us/library/ms378988.aspx (http://msdn2.microsoft.com/en-us/library/ms378988.aspx)


The SQL Server 2000 JDBC driver accepts connection URLs from the SQL Server 2005 JDBC Driver. The SQL Server 2005 JDBC Driver connection string URLs start with the following string:
jdbc:sqlserver:// ConnectionString
The SQL Server 2000 Driver for JDBC should only accept connection string URLs that start with the following string:
jdbc:microsoft:sqlserver:// ConnectionString
However, the SQL Server 2000 Driver for JDBC also accepts connections that have the following format:
jdbc:sqlserver:// ConnectionString
The exception occurs because the SQL Server 2000 Driver for JDBC is not designed to connect to a SQL Server 2005 database.
 类似资料:

相关阅读

相关文章

相关问答