----------------解决方案--------------------------------------------------------
没有啊
----------------解决方案--------------------------------------------------------
你把数据库的代码全部拷贝上来.
----------------解决方案--------------------------------------------------------
create table kh(
kid char(4) not null primary key,
kname char(20) ,
ksex char(2) default '男' check (ksex='男' or ksex='女'),
kage smallint,
ktime smalldatetime);
create table room(
rid char(4) not null primary key,
rtype smallint,
rrn smallint);
create table kr(
kid char(4) not null foreign key references kh(kid),
rid char(4) not null foreign key references room(rid),
rd smallint,
rmoney int,
primary key(kid,rid),
);
insert into kh values('0001','周楠','男',20,'2007-05-08 12:35');
insert into kh values('0002','钱勇勇','男',20,'2007-05-08 12:35');
insert into kh values('0003','陆向荣','男',20,'2007-05-08 12:35');
insert into kh values('0004','周明','男',20,'2007-05-08 12:35');
insert into kh values('0005','冯树彪','男',20,'2007-05-08 12:35');
insert into kh values('0006','胥睿','男',20,'2007-05-08 12:35');
insert into room values('0001'1,2);
insert into room values('0002'2,2);
insert into room values('0003'3,2);
insert into room values('0004'4,2);
insert into room values('0005'5,2);
insert into room values('0006'6,2);
insert into kr values('0001','0001',1,null);
insert into kr values('0002','0002',2,null);
insert into kr values('0003','0003',1,null);
insert into kr values('0004','0004',1,null);
insert into kr values('0005','0006',1,null);
insert into kr values('0006','0005',1,null);
----------------解决方案--------------------------------------------------------
我感觉好象是比较那边错了
if (rs.next()){
//text.append("\t"+"\t"+rs.getString("room_num")+"\n");
if(rs.getString("kid").trim().equals(jt.getText().trim())){
JOptionPane.showMessageDialog(null,"此房间已经满了");}
else
JOptionPane.showMessageDialog(null,"此房间空着");
}
你从数据库取来的的字符串,可能尾部加了很多空格
----------------解决方案--------------------------------------------------------
if (rs.next()){
//text.append("\t"+"\t"+rs.getString("room_num")+"\n");
if(rs.getString("kid").equals(jt.getText().trim())){
JOptionPane.showMessageDialog(null,"此房间已经满了");}
else
JOptionPane.showMessageDialog(null,"此房间空着");
}
改成
if (rs.next()){
//text.append("\t"+"\t"+rs.getString("room_num")+"\n");
if(rs.getString("kid").equals(jt.getText().trim())){
JOptionPane.showMessageDialog(null,"此房间已经满了");}
}
else
JOptionPane.showMessageDialog(null,"此房间空着");
看看
----------------解决方案--------------------------------------------------------
create table kh(
kid char(4) not null primary key,
kname char(20) ,
ksex char(2) default '男' check (ksex='男' or ksex='女'),
kage smallint,
ktime smalldatetime);
create table room(
rid char(4) not null primary key,
rtype smallint,
rrn smallint);
create table kr(
kid char(4) not null foreign key references kh(kid),
rid char(4) not null foreign key references room(rid),
rd smallint,
rmoney int,
primary key(kid,rid),
);
insert into kh values('0001','周楠','男',20,'2007-05-08 12:35');
insert into kh values('0002','钱勇勇','男',20,'2007-05-08 12:35');
insert into kh values('0003','陆向荣','男',20,'2007-05-08 12:35');
insert into kh values('0004','周明','男',20,'2007-05-08 12:35');
insert into kh values('0005','冯树彪','男',20,'2007-05-08 12:35');
insert into kh values('0006','胥睿','男',20,'2007-05-08 12:35');
insert into room values('0001'1,2);
insert into room values('0002'2,2);
insert into room values('0003'3,2);
insert into room values('0004'4,2);
insert into room values('0005'5,2);
insert into room values('0006'6,2);
insert into kr values('0001','0001',1,null);
insert into kr values('0002','0002',2,null);
insert into kr values('0003','0003',1,null);
insert into kr values('0004','0004',1,null);
insert into kr values('0005','0006',1,null);
insert into kr values('0006','0005',1,null);
别把这个贴出来了
insert into room values('0001'1,2);
insert into room values('0002'2,2);
insert into room values('0003'3,2);
insert into room values('0004'4,2);
insert into room values('0005'5,2);
insert into room values('0006'6,2);
这是啥呀
----------------解决方案--------------------------------------------------------
上面的数据库里面分别加一个逗号.
----------------解决方案--------------------------------------------------------
我试试看
----------------解决方案--------------------------------------------------------
if (rs.next()){
//text.append("\t"+"\t"+rs.getString("room_num")+"\n");
if(rs.getString("kid").equals(jt.getText().trim())){
JOptionPane.showMessageDialog(null,"此房间已经满了");}
else
JOptionPane.showMessageDialog(null,"此房间空着");
}
改成
if (rs.next()){
//text.append("\t"+"\t"+rs.getString("room_num")+"\n");
if(rs.getString("kid").equals(jt.getText().trim())){
JOptionPane.showMessageDialog(null,"此房间已经满了");}
}
else
JOptionPane.showMessageDialog(null,"此房间空着");
看看
你上面哪儿改了哦
还有封哥,按你改了之后,还不行哦
----------------解决方案--------------------------------------------------------