`

sql server2000的主要用法

阅读更多

目前项目中要使用sql server2000,因为客户使用的是sql server2000.

我使用的是精简版的数据库。

无法修改用户密码。(太坑爹了)

不过可以设置数据库初始密码:

 修改setup.ini 文件,比如我把密码修改为“123456abc”

[Options]
SAPWD="123456abc" SECURITYMODE=SQL DISABLENETWORKPROTOCOLS=0

 也可以设置实例名

[Options]
SAPWD="123456abc" SECURITYMODE=SQL DISABLENETWORKPROTOCOLS=0 INSTANCENAME="sql2000hw"

 

安装界面如下:

 

 

java 使用jdbc连接时报错:

 

原因一:sql server2000没有安装sp4

 安装sp4

 

原因二:防火墙限制

修改防火墙,允许sqlserver

 

测试代码:

package com.huang.sqlserverConn;

import java.sql.*;
public class SQLServerConnection {
	public static Connection getConnection()
	{
		 Connection conn=null;
		try {
			Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		try {
			String connURL="jdbc:microsoft:sqlserver://192.168.0.104:1433;databaseName=jj2011";
			conn=DriverManager.getConnection( connURL,"sa","123456");
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return conn;
}
	
	public static void main(String[] args) {
		Connection conn=getConnection();
		System.out.println("conn:"+conn);
	}
}

sqlserver2000的jdbc驱动 下载地址:http://pan.baidu.com/s/1eQ9t78I

sqlserver2000的补丁包SP4 下载地址:http://pan.baidu.com/s/1bnEj1bp

 

(a)建表

 

--公司信息:公司成立,办公环境,经营理念
create table t_company_info(
        id int primary key,
        detail_content ntext,
        pic_path varchar(100)	
)
 

 

 

(b)自增列

-- 产品 大类型
create table t_product_itemclass(
         id int IDENTITY (1, 1) primary key  not null,
         itemclass varchar(100) unique
);

 id 就是自增列,每插入一条记录id就会自动增加1

 

(c)外键

-- 产品小类型
create table t_product_smallclass(
        id int IDENTITY (1, 1) not null,
        small_class varchar(100) unique ,
        big_class_id int  not null,
	added_time datetime not null,
	FOREIGN KEY (big_class_id) REFERENCES t_product_itemclass (id)
);

 每个子类型都隶属于产品大类型,t_product_smallclass 的big_class_id 是外键,参考表t_product_itemclass中的主键id

 

(d)分页

select top 5 * from public.products;

 (e)sqlserver2000中的大文本使用什么类型?

使用ntext,例如:

--创建新闻
create table t_news(
	id int IDENTITY (1, 1) NOT NULL ,
	title varchar(255),
	startTime datetime ,
	endTime  datetime ,
	content ntext  NOT NULL,
	releaseTime datetime NOT NULL,
	status int  NOT NULL,
	stickTop int
)

 (f)

  • 大小: 16 KB
  • 大小: 13 KB
  • 大小: 25.5 KB
  • 大小: 50.7 KB
  • 大小: 32.5 KB
  • 大小: 64.5 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics