• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

i'm getting the error missing return statement

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm getting bello error where is the mistake in this
missing return statement
{



import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.sql.*;
//package one;

public class ContSaveAction extends Action
{
public ActionForward execute(ActionForm form,ActionMapping mapping,HttpServletRequest request,HttpServletResponse response) throws Exception
{
ContSaveForm cf=(ContSaveForm)form;
String contcode,contname;
contcode=cf.getContCode();
contname=cf.getContName();

try{

//ResultSet rs;
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc racle:thin:@localhost:wsoft","user","pass");
Statement stmt=con.createStatement();

int b=0;
b=stmt.executeUpdate("insert into RWS_CONTAMINATION_TBL values('"+contcode+"','"+contname+"')");
if(b!=0)
return mapping.findForward("loaded");


}catch(Exception e)
{
System.out.println("Exception due to:"+e);
}


/*else
return mapping.findForward("error"); */
}
}
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In normal execution of a method you have to make sure that each path has a way to exit normally through return. If you have the last line commented, then if an exception is thrown and caught, there is no path out of the method through a return statement.
 
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you just need to have a return statement at the very end of the method,

between the last two curly's...

Monk
 
PI day is 3.14 (march 14th) and is also einstein's birthday. And this is merely a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic