Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2004
    Posts
    10

    Unanswered: error while insertion...

    hi..

    when iam inserting data using jsp..its coming error of like that..the data is inserted in database..but displays error...why???

    why???

    my insertion code is as follow:

    <%@ page import =" java.sql.Date.*" %>
    <%@ page import =" java.text.SimpleDateFormat.*" %>
    <%@ page import =" java.text.DateFormat.*" %>
    <%@ page import =" java.util.Date.*" %>
    <%@ page import="java.text.*" %>
    <%@ page import="javax.servlet.*" %>
    <%@ page import="javax.servlet.http.*" %>
    <%@ page language="java" import="java.sql.*" %>
    <%@ page import="java.util.*,java.text.*"%>
    <%@ page import ="java.util.Locale.*" %>

    <%
    String sql1 ;

    ResultSet results;
    PreparedStatement sql;
    try
    {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn=DriverManager.getConnection("jdbcdbcf","scott","ttlscott");

    try
    {
    int sec_no,catg_code;
    float face_val,pur_val,int_paid,int_recd,brkr,tot_val,vo u_amt;
    java.util.Date vou_date,due_date1,due_date2,mat_date;
    String vou_no,lf_no;

    boolean doneheading = false;

    Statement s=conn.createStatement();

    String Security_No = request.getParameter("secno");
    String Ledger = request.getParameter("lfno");


    conn.setAutoCommit(false);

    PreparedStatement pstmt = conn.prepareStatement(
    ("INSERT INTO SEC_MAST_03092004 VALUES (?, ?, ?, ?, ?, ?,?,?, ?, ?, ?, ?, ?,?,?,?)"));



    pstmt.setInt(1,Integer.parseInt(request.getParamet er("secno")));



    pstmt.setInt(2,Integer.parseInt(request.getParamet er("catcode")));


    pstmt.setFloat(3,Float.parseFloat(request.getParam eter("facevalue")));


    pstmt.setFloat(4,Float.parseFloat(request.getParam eter("purvalue")));


    pstmt.setFloat(5,Float.parseFloat(request.getParam eter("intpaid")));


    pstmt.setFloat(6,Float.parseFloat(request.getParam eter("intrecvd")));

    pstmt.setFloat(7,Float.parseFloat(request.getParam eter("brokrage")));


    pstmt.setFloat(8,Float.parseFloat(request.getParam eter("tvalue")));

    pstmt.setString(9,request.getParameter("vouno"));

    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    sdf.setLenient(false);
    vou_date = sdf.parse(request.getParameter("voudate"));
    pstmt.setDate(10, new java.sql.Date(vou_date.getTime()));

    pstmt.setFloat(11,Float.parseFloat(request.getPara meter("vouamt")));



    SimpleDateFormat sdf1 = new SimpleDateFormat("dd/MM/yyyy");
    sdf1.setLenient(false);
    due_date1 = sdf1.parse(request.getParameter("due1"));
    pstmt.setDate(12, new java.sql.Date(due_date1.getTime()));

    SimpleDateFormat sdf2 = new SimpleDateFormat("dd/MM/yyyy");
    sdf2.setLenient(false);
    due_date2 = sdf2.parse(request.getParameter("due2"));
    pstmt.setDate(13, new java.sql.Date(due_date2.getTime()));

    pstmt.setString(14,request.getParameter("lfno"));

    SimpleDateFormat sdf3 = new SimpleDateFormat("dd/MM/yyyy");
    sdf3.setLenient(false);
    mat_date = sdf3.parse(request.getParameter("maturity"));
    pstmt.setDate(15, new java.sql.Date(mat_date.getTime()));

    pstmt.setString(16,request.getParameter("fk_vou_no 2"));




    pstmt.executeUpdate();

    conn.commit();
    conn.setAutoCommit(false);
    conn.setAutoCommit(true);

    sql = conn.prepareStatement("select * from SEC_MAST_03092004");

    ERROR:-


    HTTP Status 500 -

    ------------------------------------------------------------------------------- -

    type Exception report

    message

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    org.apache.jasper.JasperException
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:372)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)


    root cause

    java.lang.NullPointerException
    java.util.Calendar.setTime(Calendar.java:902)
    java.text.SimpleDateFormat.format(SimpleDateFormat .java:782)
    java.text.SimpleDateFormat.format(SimpleDateFormat .java:775)
    java.text.DateFormat.format(DateFormat.java:314)
    org.apache.jsp.MENU.security_005fmaster.security_0 05fsave1_jsp._jspService(secu rity_005fsave1_jsp.java:210)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)


    note The full stack trace of the root cause is available in the Apache Tomcat/5.0.30 logs.


    ------------------------------------------------------------------------------- -

    Apache Tomcat/5.0.30

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by abhit_kumar
    root cause

    java.lang.NullPointerException
    java.util.Calendar.setTime(Calendar.java:902)
    java.text.SimpleDateFormat.format(SimpleDateFormat .java:782)
    java.text.SimpleDateFormat.format(SimpleDateFormat .java:775)
    java.text.DateFormat.format(DateFormat.java:314)
    org.apache.jsp.MENU.security_005fmaster.security_0 05fsave1_jsp._jspService(secu rity_005fsave1_jsp.java:210)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:324)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

    Open the file "security_005fsave1_jsp.java" and check why there's a null Date at line 210.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •