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.
相关文档:
SQL 常用语句以及函数之一
SELECT --从数据库表中检索数据行和列
INSERT --向数据库表添加新数据行
DELETE --从数据库表中删除数据行
UPDATE --更新数据库表中的数据
--数据定义
CREATE TABLE --创建一个数据库表
DROP TABLE --从数据库中删除表
......
在sql语句中添加变量。
declare @local_variable data_type
声明时需要指定变量的类型,
可以使用set和select对变量进行赋值,
在sql语句中就可以使用@local_variable来调用变量
声明中可以提供值,否则声明之后所有变量将初始化为NULL。
例如:declare @id int
&nb ......
创建函数
CREATE OR REPLACE FUNCTION ntfuc(inp IN NUMBER)
RETURN NUMBER
IS
ntmp NUMBER;
BEGIN
ntmp := inp;
RETURN ntmp;
END ntfuc;
/
执行该函数时
DECLARE
rcn NUMBER;
BEGIN
rcn := ntfunc(1);
END;
/ ......
1:SQL Server数据库配置
开启服务器
托盘显示服务器启动
2:在StaAfx.h 中添加如下代码
#import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no_namespace rename("EOF","adoEOF")rena ......
SQL:Structured Query Language,1974年Boyce和Chamberlin提出.
数据定义 :CREATE,DROP
数据库查询:SELECT
数据操纵 :INSERT,UPDATE,DELETE
数据控制 :GRANT,REVOKE
一.数据的定义和修改:
1.定义基表
CREATE TABLE 表名 (<列名1 类型[NOT NULL][,列名2 类型[NOT NULL]>…[其他参数]);
关于类型:
INTEGE ......