SQL Server 2005 Driver for JDBC
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
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.
相关文档:
--测试数据
if OBJECT_ID('tb') is not null
drop table tb
go
CREATE TABLE tb(ID char(3),PID char(3),Name nvarchar(10))
INSERT tb SELECT '001',NULL ,'山东省'
UNION ALL SELECT '002','001','烟台市'
UNION ALL SELECT '004','002','招远市'
UNION ALL SELECT '003','001','青岛市'
UNION ALL SELECT '00 ......
MS SQL Server查询优化方法
作者:xmllover 2007-11-29
查询速度慢的原因很多,常见如下几种
1、没有索引或者没有用到索引(这是查询慢最常见的问题,是程序设计的缺陷)
2、I/O吞吐量小,形成了瓶颈效应。
3、没有创建计算列导致查询不优化。
4、内存 ......
[Sql]EXCEPT 和 INTERSECT关键字
http://www.cnblogs.com/treeyh/archive/2008/07/01/1232845.html
EXCEPT
从 EXCEPT 操作数左边的查询中返回右边的查询未返回的所有非重复值。
INTERSECT
返回 INTERSECT 操作数左右两边的两个查询均返回的所有非重复值。
A. 使用 EXCEPT
在示例中使用 TableA 和 TableB 中的数据。
......
我定义了一个 textarea:
<tr bgcolor="#CCCCCC" align="center" valign="bottom">
<td align="right" valign="top" class="style1" >文章内容:</td>
&nbs ......
来自:http://www.cnblogs.com/morningwang/archive/2009/01/02/1367277.html
有关分页 SQL 的资料很多,有的使用存储过程,有的使用游标。本人不喜欢使用游标,我觉得它耗资、效率低;使用存储过程是个不错的选择,因为存储过程是经过预编译的,执行效率高,也更灵活。先看看单条 SQL 语句的分页 SQL 吧。
方法1:
适用 ......