473,378 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

getting null pointer exception while entering date in sql server DB

1
Sqlserver table
QualifyDate DATETIME;
RenewalDate DATETIME
---
on Bean qualifydate
private Date QualifyDate;

private Date RenewalDate;
public Date getQualifiyDate() {
return QualifyDate;
}
public void setQualifiyDate(Date QualifyDate)
{
this.RenewalDate=RenewalDate;
}
---------------------------------------------
ON DAOImpl(java file)
try{
ppds.setDate(8,new Date(asb.getQualifiyDate().getTime()));
}
catch(NullPointerException nfe){
nfe.printStackTrace();
-------------------
try{
ppds.setDate(10,new Date(asb.getRenewalDate().getTime()));
}
catch(NullPointerException npe){
npe.printStackTrace();
}
-----------------
ON servlet
try {
Date dob = new SimpleDateFormat("YYYY-MM-DD HH:MM:SS").parse(request.getParameter("sqfdt"));
asb.setQualifiyDate(dob);
} catch (ParseException e) {
e.printStackTrace();
}
--------------
try {
Date doba = new SimpleDateFormat("YYYY-MM-DD HH:MM:SS").parse(request.getParameter("srnldt"));
asb.setRenewalDate(doba);
} catch (ParseException e) {
e.printStackTrace();
}
---------
After submitting the Form data don't get inserted to the database
instead says null pointer exception.
Please helps to resolve the Problem sir,
IDE is netbeans.
Thankyou
Sincerly Your.
Sep 15 '16 #1
1 1186
Oralloy
985 Expert 512MB
The problem is that your formatter SimpleDateFormat is not recognising the input that you gave it, so it returns NULL.

I suggest that you experiment with SimpleDateFormat in a stand-alone test program, so you can understand how it really works. If you cannot do this, then you are not going to get very far with server-side code.

Several things to try:
  1. Verify that your calls get the correct data before inserting into the database.
  2. Verify that the parsing is correct, and returns a non-NULL value.
  3. Figure out how to handle errors - do you reject all of the transaction, or keep the completed portions?
  4. Include exception output, so that we can see what really is happening.
Sep 15 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: jennifer johnson | last post by:
Hello All, I appreciate anyone's assistance. I wanted to validate user customizable field values so I changed my JSP page so that the form action would post existing form - action=<%=...
5
by: Tony Cheng | last post by:
for (int i=0; i<_request.Form.Count; i++ ) { string key = _request.Form.GetKey(i); if ( !key.Equals("formCode") && !key.Equals("formLanguage") && !key.Equals("__VIEWSTATE") &&...
1
by: zahidkhan | last post by:
Hi All, Plz help me if you can..... I have a program something like this int main(int argc,char* argv) { try { int* p = NULL;
6
by: dev24 | last post by:
Hi all, I am writing a simple method which when entered with an Int parameter performs an sql query, creates a result set, uses that resultset to get values from the object created by another...
1
by: MRamaLakshmi | last post by:
hi, I am developing an application using Java Applet which will be uploading files. Its throwing Null Pointer exception while detecting the proxy when we are trying to load the applet using Java6....
0
by: j74 | last post by:
I was testing some concepts and I came across following scenarios where include file does not seem working. Is the test code issue or some ATG setting issue? Though DSP jsp include works but jhtml...
1
by: Merdith | last post by:
String x=""; Vector From = (Vector)session.getAttribute("DATESFROM"); int isize = From.size(); Vector To = (Vector)session.getAttribute("DATESTO"); int isize2 = To.size();...
5
by: iamdennisthomas | last post by:
Hi Guys i was developing a action servlet which is actulally getting the data from a form and putting it in the db but while executing i am getting a null pointer exception /* * Generated by...
1
by: Riteshti | last post by:
Im trying this java code to export data from database using sql query, But getting a null pointer exception. getting no clue to remove it . Im getting this exception at line no 26. try { ...
7
by: jinnejeevansai | last post by:
Hii,I was trying to solve a problem but i don't get why my program is showing null pointer exception on the commented line.Can someone explain the reason. import java.util.*; class cod1{ ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.