Missing Return Statement?
3 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, May 21, 2002 09:19 AM

I'm having a problem compiling this code, I keep getting an error sayin missing return statement, I can't see where the problem is, could someone please tell me. Thanks alot!!!! public class ReturnInfo { public static String GetParameters() { try { // Hashtable for environmental information Hashtable env = new Hashtable(); System.out.println("Create initial context..."); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://localhost/dc=may,dc=ie"); env.put(Context.SECURITY_PRINCIPAL, "cn=Keith,dc=may,dc=ie"); env.put(Context.SECURITY_CREDENTIALS,    More>>
			
I'm having a problem compiling this code, I keep getting an
error sayin missing return statement, I can't see where the
problem is, could someone please tell me. Thanks alot!!!!


public class ReturnInfo {
public static String GetParameters()
{
try { // Hashtable for environmental information
Hashtable env = new Hashtable();
System.out.println("Create initial context...");

env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost/dc=may,dc=ie");
env.put(Context.SECURITY_PRINCIPAL, "cn=Keith,dc=may,dc=ie");
env.put(Context.SECURITY_CREDENTIALS, "optilab");

// Get a reference to a directory context
DirContext ctx = new InitialDirContext(env);
System.out.println("Context : "+ctx.getNameInNamespace());

String MY_ATTRS[]={"CrecheInfo"};
SearchControls constraints = new SearchControls();
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);

NamingEnumeration results = ctx.search("","ou=Social",constraints);
if (results == null){ System.out.println("Results equals null value");}
while (results != null && results.hasMore())
{
SearchResult sr = (SearchResult) results.next();
Attributes ar = ctx.getAttributes("ou=Social",MY_ATTRS);
Attribute attr=ar.get(MY_ATTRS[0]);
for(Enumeration vals=attr.getAll();vals.hasMoreElements();)
{
return(String.valueOf(vals.nextElement()));
}//END FOR LOOP
}// END WHILE LOOP
// } // END IF HASCHILDREN

ctx.close();
} //END TRY
catch (Exception e) { e.printStackTrace(); System.exit(1); }
} //END GetParameters()
}//END ReturnInfo
   <<Less

Re: Missing Return Statement?

Posted By:   Anonymous  
Posted On:   Thursday, May 23, 2002 01:42 AM


Thanks for the suggestions, the solution to the problem is
to put the return statement outside the catch
statement so that it can be recognised. Thanks for help

Re: Missing Return Statement?

Posted By:   Simon_Ablett  
Posted On:   Tuesday, May 21, 2002 09:35 AM

Sounds like the compiler thinks that you have one end-brace too many. Are you sure that in the version of the code you compile the end brace marked 'END IF HASCHILDREN' is actually commented out?

Regards

Re: Missing Return Statement?

Posted By:   Simon_Ablett  
Posted On:   Tuesday, May 21, 2002 09:22 AM

Well, for a start you have a for loop the contents of which are a return statement. Is that what you meant?

Regards.
About | Sitemap | Contact