目前項目中要使用sql server2000,因為客戶使用的是sql server2000.
無法修改使用者密碼。(太坑爹了)
不過可以設定資料庫初始密碼:

修改setup.ini 檔案,比如我把密碼修改為“123456abc”
[options]
sapwd="123456abc" securitymode=sql disablenetworkprotocols=0
也可以設定執行個體名
sapwd="123456abc" securitymode=sql disablenetworkprotocols=0 instancename="sql2000hw"
安裝界面如下:
原因一: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();
}
string connurl="jdbc:microsoft:sqlserver://192.168.0.104:1433;databasename=jj2011";
conn=drivermanager.getconnection( connurl,"sa","123456");
} catch (sqlexception e) {
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)