| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 521 人关注过本帖
标题:数据库提交
只看楼主 加入收藏
fgywh
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-6-28
收藏
 问题点数:0 回复次数:2 
数据库提交
  我的jsp和mysql的一个系统。在提交的标单中(字符型)有两个只能是空的才能提交正常。要不就出现异常。不能用。请问大家这是怎么回事啊?
搜索更多相关主题的帖子: 数据库 系统 jsp mysql 字符 
2006-06-28 20:33
神vLinux飘飘
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:浙江杭州
等 级:贵宾
威 望:91
帖 子:6140
专家分:217
注 册:2004-7-17
收藏
得分:0 
出现什么异常?

淘宝杜琨
2006-06-29 07:28
fgywh
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-6-28
收藏
得分:0 

登录代码:


<head>
<title>11111</title>

</head>

<html><%
String _addDoctor="";
int age=0,sex=0,spDays[]=new int[14];
String did="",name="",level="",spe="",section="",spt="",phone="";;
Admin admin=(Admin)session.getAttribute("admin");

if(admin==null)
_addDoctor="<a href=\"login.jsp\">请先登录</a>";

else{
if(request.getParameter("add")!=null){
age=Integer.parseInt(request.getParameter("age"));
name=request.getParameter("name");
sex=Integer.parseInt(request.getParameter("sex"));
did=request.getParameter("did");
try{
spDays=Util.parseSpDays(spt);
}
catch(NumberFormatException nfe){
_addDoctor="非法输入";
}

int a=admin.addDoctor(did,name,age,sex,level,spe,spDays,phone,section);
switch(a){
case 1:
_addDoctor="插入成功";
break;
case 0:
_addDoctor="一般异常";
break;
case -1:
_addDoctor="数据库异常";
break;
case -2:
_addDoctor="已存在";
break;
}
}
}
%>

<body bgcolor="#FFFFFF">
<table width="770" height="423" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">
<tr>
<td height="421" bgcolor="#FFFFFF"><%@ include file = "../include/head.inc" %>
<table width="770" height="290" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<%@ include file="../include/admin.inc" %>
<td width="603" align="center" valign="top">
<table width="100%" height="85%" border="0" cellpadding="3" cellspacing="1" bgcolor="#666666">
<tr>
<td width="100%" height="257" align="center" valign="top" bgcolor="E3EDFF">
<br>
<p><%=_addDoctor%></p>
<form action="addDoctor.jsp?add=true" name="addDoctor" method="POST">
<p>编号:<input type="text" name="did" value="0"/></p>
<p>姓名:<input type="text" name="name"/></p>
<p>年龄:<input type="text" name="age" value="0"/></p>
</td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
编号和姓名只能是空才能提交。填上就提示数据库异常
捕获异常代码

返回值-执行结果代码:
* 1-操作成功
* 0-抛出一般异常
* -1-抛出数据库异常
* -2信息已存在

catch(SQLException sqle){
Debug.log(Debug.getExceptionMsg(sqle));
conn.rollback();
res= -1;
}
catch(IllegalArgumentException iae){
Debug.log(Debug.getExceptionMsg(iae));
res= -2;
}
catch(Exception e){
res=0;
}
finally{
return res;
debug也是个定义类

2006-06-29 08:19
快速回复:数据库提交
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011514 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved