日期:2014-05-18  浏览次数:20703 次

jsp中添加一条新的记录问题,谢谢
如果输入数据库中已经存在的记录会提示已经有了,而当我输入一条数据库中不存在的记录时,会弹出“添加设备信息失败”,不知道为什么,很急。
代码如下:
equi_add.jsp
<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "java.sql.* "   %>
<html>
<head>
<title> 添加设备 </title>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
<style   type= "text/css ">
<!--
.STYLE1   {font-family:   "宋体 "}
-->
</style>
</head>
<script   language= "javascript ">
function   mycheck(){
if   (form1.EquiNo.value== " "){
alert( "请输入主设备号! ");form1.EquiNo.focus();return;
}
if   (form1.LabId.value== " "){
alert( "请输入实验台编号! ");form1.LabId.focus();return;
}
if   (form1.RoomId.value== " "){
alert( "请输入所属实验室! ");form1.RoomId.focus();return;
}
if   (form1.Charger.value== " "){
alert( "请输入设备负责人! ");form1.Charger.focus();return;
}
if   (form1.MacAddr.value== " "){
alert( "请输入MAC地址! ");form1.MacAddr.focus();return;
}
if   (form1.PowerAddr.value== " "){
alert( "请输入电源控制地址! ");form1.PowerAddr.focus();return;
}
form1.submit();
}
</script>
<body>
<table   width= "100% "     border= "0 "   cellspacing= "0 "   cellpadding= "0 ">
    <tr>
        <td>
<table   width= "777 "   height= "609 "     border= "0 "   align= "center "   cellpadding= "0 "   cellspacing= "0 "   bgcolor= "#FFFFFF ">
    <tr>
        <td   valign= "top "> <table   width= "100% "     border= "0 "   cellspacing= "0 "   cellpadding= "0 "   class= "tableBorder_LTR ">
            <tr>
                <td   height= "30 "   align= "center "   bgcolor= "#eeeeee "> ≡≡≡添加设备≡≡≡ </td>
            </tr>
        </table>
<table   width= "100% "   height= "396 "     border= "0 "   cellpadding= "0 "   cellspacing= "0 "   class= "tableBorder_LBR ">
                <tr>
                    <td   width= "10 "   height= "395 "   valign= "top "> &nbsp; </td>
                    <td   width= "767 "   valign= "top "> <table   width= "100% "   height= "56 "     border= "0 "   cellpadding= "0 "   cellspacing= "0 ">
                        <tr>
        &nbs