Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 24th, 2005, 07:08 AM
abhit_kumar abhit_kumar is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 22 abhit_kumar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 3 sec
Reputation Power: 0
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_no2"));




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

Reply With Quote
  #2  
Old January 28th, 2005, 02:59 AM
gertcuppens's Avatar
gertcuppens gertcuppens is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 118 gertcuppens User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 28 m 17 sec
Reputation Power: 15
If i see a nullpointer exception, I'm wondering if you're sure that you get all
the values you need from your request. Are you sure the user has provided them all?
Did you write a check to be sure that all the values of the form are filled in ?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > error while insertion...


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap