<%
String emi1;
String repo1;
String arr1;
String reso1;
String pi1;
emi1=request.getParameter("e"+count);
repo1=request.getParameter("repo"+count);
arr1=request.getParameter("a"+count);
reso1=request.getParameter("r"+count);
pi1=request.getParameter("pi"+count);
if(emi1!=null && repo1!=null && arr1!=null && reso1!=null && pi1!=null)
{
String ReserveDt = request.getParameter("ReserveDate");
System.out.println(emi1);
System.out.println(repo1);
System.out.println(arr1);
System.out.println(reso1);
System.out.println(pi1);
System.out.println(ReserveDt);
String sql=("BEGIN DECLARE @DT DATE;DECLARE @CIR NVARCHAR(2);SET @CIR='"+circle+"' DECLARE @MON NVARCHAR(2); DECLARE @DAY NVARCHAR(2); "
+"DECLARE @YEAR NVARCHAR(4);DECLARE @curr NVARCHAR(50); DECLARE @reg nvarCHAR(3);"
+"set @reg='"+utype+"' SET @DT='"+ReserveDt+"' SET @day=(SELECT DATEPART(day,@DT)) "
+"SET @MON=(SELECT DATEPART(month,@DT)) SET @year=(SELECT DATEPART(year,@DT)) "
+"SET @curr=@reg+convert(nvarchar(2),@DAY)+convert(nvarchar(2),@MON)+convert(nvarchar(4),@YEAR)+CONVERT(NVARCHAR(2),@CIR) "
+"INSERT INTO [DCRA].[dbo].[SAM]([REGION],[CIRCLE],[TOTAL],[EMI],[REPO],[REPO ARREAR],[RES],[CURR_DATE],[PI],[DATAID]) "
+"VALUES (@reg,@CIR,0.24,"+emi1+","+repo1+","+arr1+","+reso1+",'"+ReserveDt+"',"+pi1+",@curr) end");
System.out.println(sql);
stmt=con.createStatement();
stmt.executeUpdate(sql);
System.out.println(sql);
if("stmt"!=null)
{
response.sendRedirect("Add.jsp");
}
}
count++;
System.out.println(count+"my count");
}
}
catch(Exception e)
{
%>
<script type="text/javascript">
alert("Data is alredy insert or please check your data!");
</script>
<%
e.printStackTrace();
}
%>
我是jsp的新手,我将值插入表中,那时它给了我错误。我在add.jsp.how中显示数据已成功添加以解决此问题。请帮助我解决此问题。
答案 0 :(得分:0)
我没有找到你的尝试块而没有尝试你也无法捕捉到正确的异常 把这一行放在你的代码中
System.out.println(e.toString());
以便您获得正确的例外