Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old August 26th, 2002, 03:19 AM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Null pointer exception error

<%
String changesrno = request.getParameter("Changesrno");
String changename = request.getParameter("Changename");
String changefname = request.getParameter("Changefname");
//change first name to uppercase
String fnameU = changefname.substring(0,1).toUpperCase() + changefname.substring(1);
String changelname = request.getParameter("Changelname");
//change last name to uppercase
String lnameU = changelname.substring(0,1).toUpperCase() + changelname.substring(1);
String changeremarks = request.getParameter("Changeremarks");
String changestatus = request.getParameter("Changestatus");
//add space between fname and lname
String changefullname = fnameU + " " +lnameU;
//add space between fname and lname
String AAname = fnameU + " " +lnameU;
//add space between fname and lname
String email = fnameU + " " +changelname;
//replace space with underscore
String emailreplace = email.replace(' ','_');
//change email to lower case
String emailL = emailreplace.toLowerCase()+"@moe.edu.sg";
//check if user clicks on which button
String check = request.getParameter("save");
String check2 = request.getParameter("reset");

Connection connection = null;
Statement statement = null;
ResultSet rs = null;
ResultSet rs2 = null;
ResultSet rs3 = null;

String full_name;
boolean checking=false;
String email_Add;
boolean checking2=false;

//Class.forName("org.gjt.mm.mysql.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "", "");
statement = connection.createStatement();

rs2 = statement.executeQuery("SELECT * from SR_MsgSvc_Creation");
//check if full name exist
while(rs2.next())
{
full_name = rs2.getString("Full_Name");
if(changefullname.equalsIgnoreCase(full_name))
{
//if exist, set checking to true
checking=true;
break;
}
}

rs3 = statement.executeQuery("SELECT Email_Address from SR_MsgSvc_Creation");
//check if emailaddress exist
while(rs3.next())
{
email_Add = rs3.getString(1);
if(emailL.equalsIgnoreCase(email_Add))
{
//if exist, set checking to true
checking2=true;
break;
}
}

//if user clicks on the save as rejected button, do the following queries
if (check != null)
{
if(checking == false || checking2 == false)
{
rs = statement.executeQuery("UPDATE SR_MsgSvc_Creation SET First_Name= '"+fnameU+"' where SRNo='" + changesrno + "' ");
rs = statement.executeQuery("UPDATE SR_MsgSvc_Creation SET Last_Name= '"+lnameU+"' where SRNo='" + changesrno + "' ");
rs = statement.executeQuery("UPDATE SR_MsgSvc_Creation SET Full_Name= '"+changefullname+"' where SRNo='" + changesrno + "' ");
rs = statement.executeQuery("UPDATE SR_MsgSvc_Creation SET AA_UserName= '"+AAname+"' where SRNo='" + changesrno + "' ");
rs = statement.executeQuery("UPDATE SR_MsgSvc_Creation SET Email_Address= '"+emailL+"' where SRNo='" + changesrno + "' ");
rs = statement.executeQuery("UPDATE SR_MsgSvc_Creation SET SRStatus = \"Rejected\" where SRNo='" + changesrno + "' ");
out.println("Data updated!!!");
}
else{out.println("Error. Duplicate name or email address founded");}
}
else{}

//user clicks on the unreject button, do the following queries
if (check2 != null)
{
//System.out.println("3"+checking);
// System.out.println("4"+checking2);
if(checking == false || checking2 == false)
{
rs = statement.executeQuery("UPDATE SR_MsgSvc_Creation SET First_Name= '"+fnameU+"' where SRNo='" + changesrno + "' ");
rs = statement.executeQuery("UPDATE SR_MsgSvc_Creation SET Last_Name= '"+lnameU+"' where SRNo='" + changesrno + "' ");
rs = statement.executeQuery("UPDATE SR_MsgSvc_Creation SET Full_Name= '"+changefullname+"' where SRNo='" + changesrno + "' ");
rs = statement.executeQuery("UPDATE SR_MsgSvc_Creation SET AA_UserName= '"+AAname+"' where SRNo='" + changesrno + "' ");
rs = statement.executeQuery("UPDATE SR_MsgSvc_Creation SET Email_Address= '"+emailL+"' where SRNo='" + changesrno + "' ");
rs = statement.executeQuery("UPDATE SR_MsgSvc_Creation SET SRStatus = \"Pending\" where SRNo='" + changesrno + "' ");
out.println("Data updated!!!");
}
else{out.println("Error. Duplicate name or email address founded");}
}
else{}

%>
<!--close the connection to database, resultset and statement-->
<%
rs.close();
rs2.close();
rs3.close();
statement.close();
connection.close();
%>

how come i encounter a null pointer exception error???
pls help...

Reply With Quote
  #2  
Old August 27th, 2002, 12:14 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
That's a lot of code...
What line is the error being thrown on? (And what's on that line?)

Reply With Quote
  #3  
Old August 27th, 2002, 12:43 AM
peter83 peter83 is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 19 peter83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i found out that it does not go into the second if statement which is :
if(checking == false || checking2 == false)

this line actually checks for if there are any duplicate name and email address that the user entered.

Pls reply asap...

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Null pointer exception error


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway