帮帮看我的表建的有问题吗

艾小仙 2011-11-17 07:09:06

drop table request;
drop table requesttype;
drop table requesttemplate;
drop table user;
drop table usertype;

--创建用户类型表
create table usertype
(
id int(5) primary key not null,
name varchar(10) not null
);
--创建用户表
create table user
(
id int(5) primary key not null,
username varchar(20) not null,
userpwd varchar(20) default 'abc123_',
email varchar(30),
roleid int(5) ,
reportmanagerid int(5),
foreign key(reportmanagerid) references user(id),
foreign key(roleid) references usertype(id)
);
--创建请求模板
create table requesttemplate
(
id int(5) primary key not null,
summary varchar(100) not null,
reason varchar(100) not null,
forwhomid int(5) not null,
preferredtime Date not null,
steps varchar(600) not null,
foreign key(forwhomid) references user(id)
);
commit;
--请求类型表
create table requesttype
(
id int(5) primary key not null,
name varchar(30) not null,
templateid int(5) not null,
engineervisible boolean ,
foreign key(templateid) references requesttemplate(id)
);


--创建请求表
create table request
(
id int(10) primary key not null,
requesterid int(5) not null,
requestdate date not null,
requesttypeid int(5) not null,
executorid int(5),
approveddate date,
title varchar(50) not null,
contentid int(5) not null,
status int(5),
foreign key(contentid) references requesttemplate(id),
foreign key(requesterid) references user(id),
foreign key(requesttypeid) references requesttype(id),
foreign key(executorid) references user(id)
);
commit;


--插入请求模板
insert into requesttemplate values(1,'do not limit the download',
'we all need software to update ourselves',
1,
'2011-11-17',
'1.release to the download for a short time;
2.watch out for the situation;
3.if there is no any problem we can go through it');

insert into requesttemplate values(2,'update the hardware',
'we all need best hardware to work better',
2,
'2011-11-20',
'1.update a part of computer;
2.watch out for the situation;
3.if there is no any problem we can go through it');

insert into requesttemplate values(3,'do not limit the website access',
'we all need more resources to work',
3,
'2011-11-23',
'1.release a part of the website access;
2.watch out for the situation;
3.if there is no any problem we can go through it');
commit;
--插入请求类型
insert into requesttype(id,name,templateid) values(1,'Software Download',1);
insert into requesttype(id,name,templateid) values(2,'Hardware Issue',2);
insert into requesttype(id,name,templateid) values(3,'Website Access',3);
commit;
--插入用户类型
insert into usertype values(1,'Engineer');
insert into usertype values(2,'ITManager');
insert into usertype values(3,'Admin');
insert into usertype values(4,'SDM');
insert into usertype values(5,'ITStaff');
commit;
--插入用户
insert into user(id,username,userpwd) values(1,'awl','123');
insert into user(id,username,userpwd) values(2,'irwin','1123');
insert into user(id,username,userpwd) values(3,'harris','123');
insert into user(id,username,userpwd) values(4,'好人','123');
commit;

...全文
99 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yh4818 2011-11-22
  • 打赏
  • 举报
回复
jsp中的元素
1) 脚本元素
a) 声明(Declaration)
语法: <%!声明的内容%>
作用: 在servlet中声明一些成员变量、成员方法和内部类
特点: 声明被翻译进servlet后变成了成员变量、成员方法和内部类
注意: 不能使用表达式和隐含对象

b) 表达式(Expression)
语法: <%=expression%>
作用: 将expression输出到out(输出流)中,expression可以是算术、逻辑、关系表达式、变量、有返回值的方法、jsp中的9种隐含对象。
9种隐含对象:
page pageContext request response session application out config exception

特点: 表达式翻译进servlet后变成了out.print(expression),该代码处于
_jspService()方法中;

注意: expression都一律被转换成字符串后再写到输出流out(JspWriter)中。另外,expression中不能有分号(;)。

c) 脚本(Scriptlet)
语法: <%java code%>
作用: 在jsp中嵌入java代码,不能嵌入成员变量、成员方法。
特点: 脚本被翻译进servlet的_jspService()方法中。

2) 指令元素
a) page指令
语法: <%@ page attributeName="attribuerValue"...%>
作用: 利用page指令中的属性可以和容器进行通信,这些属性的设置对整个jsp都有影响。

b) include指令
语法: <%@ include file="url"%>,称为静态导入(静态包含)
作用: 在一个页面中导入另一个页面的内容(这些内容一般不会有变化,如公司的标题和版权等信息)。
特点: 在jsp翻译成servlet后就将被导入的页面内容嵌入到servlet中。
导入时间发生在翻译阶段。
被导入的资源: html、xml、jsp等

优点: 执行效率高
缺点: 当被导入页面的内容发生变化,那么jsp必须要重新被翻译。

c) taglib指令
<%@ taglib uri="" prefix=""%>
指定在jsp中要使用的标签库描述文件(*.tld)的路径

3) 动作元素(jsp自带的标准标签)
语法: <jsp:tagName/>

a) 动态导入(动态包含)
语法: <jsp:include page="url" flush="true|false"/> 或者
<jsp:include page="url" flush="true|false">
{<jsp:param …/>}*
</jsp:include>

特点: 动态导入发生在执行阶段,也就是在运行serlvet的时候才动态生成被导入页面的内容,然后嵌入到调用页面,最后将两个页面的内容一起返回给客户端。
注意: 在翻译阶段并没有生成被导入页面的内容。

缺点: 执行效率没有静态导入高
优点: 如果被导入页面的内容发生变化,调用页面不必重新翻译。

b) forward(服务器内部跳转)
语法: <jsp:forward page="url"/>或者
<jsp:forward page="url">
{<jsp:param …/>}*
</jsp:forward>
yh4818 2011-11-21
  • 打赏
  • 举报
回复


public class MemberAction extends ActionSupport {

private static final long serialVersionUID = 6932130853712561143L;
private MemberinfoService service = (MemberinfoServiceImpl) BeanFactory
.getBean(BeanFactory.MEMBERINFOSERVICE);
private BlackrecordService serviceBlack = (BlackrecordService) BeanFactory
.getBean(BeanFactory.BLACKRECORSERVICE);

private Memberinfo member;
private String authCode;
private String information = "yaohai";

private String newPasswd;

public String getNewPasswd() {
return newPasswd;
}

public void setNewPasswd(String newPasswd) {
this.newPasswd = newPasswd;
}

// /登录接收数据
private String username;
private String password;
private String autoLogin;

// /前十名用户排名 加 上线人数
private List<Memberinfo> pointrow;
private List<Memberinfo> blackList = new ArrayList<Memberinfo>();

// //找回密码接收数据
private String accusername;
private String accquestion;
private String accanswer;

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getAutoLogin() {
return autoLogin;
}

public void setAutoLogin(String autoLogin) {
this.autoLogin = autoLogin;
}

public List<Memberinfo> getPointrow() {
return pointrow;
}

public void setPointrow(List<Memberinfo> pointrow) {
this.pointrow = pointrow;
}

public String getAccusername() {
return accusername;
}

public void setAccusername(String accusername) {
this.accusername = accusername;
}

public String getAccquestion() {
return accquestion;
}

public void setAccquestion(String accquestion) {
this.accquestion = accquestion;
}

public String getAccanswer() {
return accanswer;
}

public void setAccanswer(String accanswer) {
this.accanswer = accanswer;
}

public Memberinfo getMember() {
return member;
}

public void setMember(Memberinfo member) {
this.member = member;
}

public String getAuthCode() {
return authCode;
}

public void setAuthCode(String authCode) {
this.authCode = authCode;
}

// //通过提示问题和保密答案找到密码
public String findpassword() {
HttpServletRequest request = ServletActionContext.getRequest();
if (accusername == null || accanswer == null || accquestion == null
|| accusername.trim().length() == 0
|| accanswer.trim().length() == 0
|| accquestion.trim().length() == 0)
return ERROR;
try {
String newpass = service.getBackPasswd(accusername, accquestion,
accanswer);
if (newpass == null) {
request.setAttribute("newpass", "答案错误!请重试 !");
return ERROR;
}
request.setAttribute("newpass", newpass);
} catch (Exception e) {
return ERROR;
}
return SUCCESS;
}

// /登录验证
public String login() {

HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
HttpSession session = request.getSession();
ServletContext application = ServletActionContext.getServletContext();
try {
this.pointrow = service.findMemberinfoByNum(10);// //积分排名
application.setAttribute("appli",pointrow);

} catch (Exception e1) {
e1.printStackTrace();
}
String nickname = (String) session.getAttribute("nickname");
String password = (String) session.getAttribute("password");
if (this.username == null && nickname == null) {
System.out.println(this.username + nickname + "return input");
return INPUT;
}
if (this.username == null || this.password == null
|| this.username.length() == 0 || this.password.length() == 0) {// ///自动登录,不要验证码
this.username = nickname;
this.password = password;
autoLogin = "0";
} else {// /非自动登录,要验证码
String autostr = (String) ActionContext.getContext().getSession()
.get("authCode");
if (!authCode.equals(autostr)) {
addActionError("验证码错误!");
System.out.println("验证码错误");
information="验证码错误,请重新登录!";
request.setAttribute("information",information);
return ERROR;
}
}
try {
System.out.println("自动登录 =" + autoLogin);
if (autoLogin == null)// /没有设置自动登录
{// //删除cookie
Cookie deletenickname = new Cookie("nickname", null);
Cookie deletepassword = new Cookie("password", null);
deletenickname.setMaxAge(0);// 删除该Cookie
deletepassword.setMaxAge(0);
response.addCookie(deletenickname);
response.addCookie(deletepassword);
System.out.println("没有设置自动登录 ");
} else {// /设置自动登录
// //添加cookie
Cookie addnickname = new Cookie("nickname", this.username);
Cookie addpassword = new Cookie("password", this.password);
addnickname.setMaxAge(888888);
addpassword.setMaxAge(888888);
response.addCookie(addnickname);
response.addCookie(addpassword);
System.out.println("已经设置自动登录 ");
}
Memberinfo m = service.login(this.username, this.password);
System.out.println(this.username);
System.out.println(this.password);
if (m == null) {
System.out.println("登录失败");
information="用户名或密码错误,请重新登录!";
request.setAttribute("information",information);
return ERROR;
}
// //加载用户信息,显示到页面
information = "";
Date da=m.getRegisterdate();
blackList = serviceBlack.listBlack(username);
System.out.println("blackList************");
session.setAttribute("black", blackList);
if (da == null)
session.setAttribute("lastDate", "您是第一次登录");
else {
String str = (da.getYear()+1900)+"年"+da.getMonth()+"月"+da.getDate()+"日"+da.getHours()+"时"+da.getMinutes()+"分";
session.setAttribute("lastDate", "上次登录时间是:"+ str);
}
session.setAttribute("memberinfo", m);
session.setAttribute("grade", m.getGraderecord().getGradename());
session.setAttribute("createinfo", "修改用户空间");
int onlinenum = service.findMemberinfoOnline();// /设置上线人数
application.setAttribute("online", onlinenum);
System.out.println("登录成功");
information="";
session.setAttribute("informaton",information);
return SUCCESS;
} catch (Exception e) {
e.printStackTrace();
information=e.getMessage();
session.setAttribute("informtion", information);
return ERROR;
}
}

public String logout() {
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
HttpSession session = request.getSession();
Memberinfo member = (Memberinfo) session.getAttribute("memberinfo");
try {
service.logout(member.getNickname());
Cookie c1 = new Cookie("nickname", null);
Cookie c2 = new Cookie("password", null);
c1.setMaxAge(0);
c2.setMaxAge(0);
response.addCookie(c1);
response.addCookie(c2);
session.removeAttribute("memberinfo");
session.removeAttribute("lastDate");
return SUCCESS;
} catch (MemberinfoServiceException e) {
e.printStackTrace();
return ERROR;
}
}
public String findPassword() {
HttpServletRequest request = ServletActionContext.getRequest();
try {
if (service != null) {
String newPassword = service.getBackPasswd(
member.getNickname(), member.getPasswordquestion(),
member.getPasswordanswer());
request.setAttribute("info", newPassword);
} else {
System.out.println("service is null");
}
return SUCCESS;
} catch (MemberinfoServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return ERROR;
}
}

}
yh4818 2011-11-21
  • 打赏
  • 举报
回复
package com.briup.run.common.exception;

public class DataAccessException extends Exception {

private static final long serialVersionUID = 1L;

public DataAccessException() {
super();
}

public DataAccessException(String message, Throwable cause) {
super(message, cause);
}

public DataAccessException(String message) {
super(message);
}

public DataAccessException(Throwable cause) {
super(cause);
}
}
caitianxiwo 2011-11-21
  • 打赏
  • 举报
回复
no delete cascade no update cascade
小小_happly 2011-11-18
  • 打赏
  • 举报
回复
primary key这个约束本来就不能有null值,不需要not null,问题是没问题,关键就在你建表的顺序跟给表插数据的顺序对不对了,如果按照你写的这个顺序去做的话,就会有问题了
litiebiao2012 2011-11-18
  • 打赏
  • 举报
回复
你想问什么呢?

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧