-1
<%
      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();
}
%>

I am very new into jsp , i am inserting the value into table that time it gives me error. I am showing data is added successfully in add.jsp.how to resolve this problem.please help me to resolve this problem.

fabian
  • 80,457
  • 12
  • 86
  • 114
user2866575
  • 15
  • 1
  • 4

1 Answers1

0

i didnt find your try block without try you can not catch proper exception and also put this line in your code

System.out.println(e.toString());

so that you get proper exception

Nirav Prajapati
  • 2,987
  • 27
  • 32
  • `System.out.println(e.toString());` should be unnecessary; `e.printStackTrace();` already prints the exception along with a full stack trace. – awksp Jun 03 '14 at 04:26