wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes i'm getting the error missing return statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "i Watch "i New topic
Author

i'm getting the error missing return statement

siva sankara rao
Greenhorn

Joined: Nov 22, 2005
Posts: 3
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"); */
}
}
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
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.
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
you just need to have a return statement at the very end of the method,

between the last two curly's...

Monk


You down with OOP? Yeah you know me!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: i'm getting the error missing return statement
 
Similar Threads
i'm getting the error missing return statement
Error in struts program
I m getting error '[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.'
HTTP Status 404 - Servlet action is not available
i'm getting the error missing return statement