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:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old August 25th, 2002, 10:50 PM
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
return error.

while(rs2.next())
{
full_name = rs2.getString(1);
if(full_name.equalsIgnoreCase(changefullname))
{

return true;
}
else
{
return false;
}
}

my error is:'return' with value from void
pls help...

Reply With Quote
  #2  
Old August 26th, 2002, 12:11 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
You need:

public boolean function( String changefullname ) {

...

}

or something like that.

Reply With Quote
  #3  
Old August 26th, 2002, 12:47 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
but i am doing jsp. how do i add the statement that u mentioned...

is there another way???

Reply With Quote
  #4  
Old August 26th, 2002, 02:09 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 have changed to smthing like this however, even when there is a similiar record in the database, it still adds.

<%
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 Full_Name from SR_MsgSvc_Creation");
//check if full name exist
while(rs2.next())
{
full_name = rs2.getString(1);
if(full_name.equalsIgnoreCase(changefullname))
{
//if exist, set checking to true
checking=true;
break;
}
//if not exist, set checking to false
else
{
checking=false;
break;
}
}

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

//if user clicks on the save as rejected button, do the following queries
if (check != null)
{
//System.out.println("1"+checking);
//System.out.println("2"+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 = \"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();
%>

Reply With Quote
  #5  
Old August 27th, 2002, 12:31 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
You can only return a value from a function. You're not using a function, so no return. As for your code, it will run faster if you do your check in the SQL statement, rather than with java. Something like:
Code:
 rs2 = statement.executeQuery("SELECT Full_Name FROM SR_MsgSvc_Creation WHERE Full_Name = " + changefullname);

If rs2 has any records in it, then the value already exists. This will execute faster than getting all of the records and looking for the value yourself.

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > return 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